Skip to content

Commit 54c4e51

Browse files
authored
Merge pull request #5179 from compnerd/spawn
Process: unwrap the `posix_spawnattr_t` on Android
2 parents 9dd8777 + d2de975 commit 54c4e51

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Sources/Foundation/Process.swift

+6
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,12 @@ open class Process: NSObject, @unchecked Sendable {
944944
var spawnAttrs: posix_spawnattr_t = posix_spawnattr_t()
945945
#endif
946946
try _throwIfPosixError(posix_spawnattr_init(&spawnAttrs))
947+
#if os(Android)
948+
guard var spawnAttrs else {
949+
throw NSError(domain: NSPOSIXErrorDomain, code: Int(errno),
950+
userInfo: [NSURLErrorKey:self.executableURL!])
951+
}
952+
#endif
947953
try _throwIfPosixError(posix_spawnattr_setflags(&spawnAttrs, .init(POSIX_SPAWN_SETPGROUP)))
948954
#if canImport(Darwin)
949955
try _throwIfPosixError(posix_spawnattr_setflags(&spawnAttrs, .init(POSIX_SPAWN_CLOEXEC_DEFAULT)))

0 commit comments

Comments
 (0)