Skip to content

Commit bb7e080

Browse files
committed
Process: Adapt #2928 for Android
1 parent 0e18860 commit bb7e080

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Sources/Foundation/Process.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -944,16 +944,16 @@ open class Process: NSObject {
944944
try _throwIfPosixError(_CFPosixSpawnFileActionsAddClose(fileActions, fd))
945945
}
946946

947-
#if canImport(Darwin)
947+
#if canImport(Darwin) || os(Android)
948948
var spawnAttrs: posix_spawnattr_t? = nil
949-
try _throwIfPosixError(posix_spawnattr_init(&spawnAttrs))
950-
try _throwIfPosixError(posix_spawnattr_setflags(&spawnAttrs, .init(POSIX_SPAWN_SETPGROUP)))
951-
try _throwIfPosixError(posix_spawnattr_setflags(&spawnAttrs, .init(POSIX_SPAWN_CLOEXEC_DEFAULT)))
952949
#else
953950
var spawnAttrs: posix_spawnattr_t = posix_spawnattr_t()
951+
#endif
954952
try _throwIfPosixError(posix_spawnattr_init(&spawnAttrs))
955953
try _throwIfPosixError(posix_spawnattr_setflags(&spawnAttrs, .init(POSIX_SPAWN_SETPGROUP)))
956-
954+
#if canImport(Darwin)
955+
try _throwIfPosixError(posix_spawnattr_setflags(&spawnAttrs, .init(POSIX_SPAWN_CLOEXEC_DEFAULT)))
956+
#else
957957
// POSIX_SPAWN_CLOEXEC_DEFAULT is an Apple extension so emulate it.
958958
for fd in 3 ... findMaximumOpenFD() {
959959
guard adddup2[fd] == nil &&

0 commit comments

Comments
 (0)