Skip to content

Process: Adapt #2928 for Android #2942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Sources/Foundation/Process.swift
Original file line number Diff line number Diff line change
Expand Up @@ -944,16 +944,16 @@ open class Process: NSObject {
try _throwIfPosixError(_CFPosixSpawnFileActionsAddClose(fileActions, fd))
}

#if canImport(Darwin)
#if canImport(Darwin) || os(Android)
var spawnAttrs: posix_spawnattr_t? = nil
try _throwIfPosixError(posix_spawnattr_init(&spawnAttrs))
try _throwIfPosixError(posix_spawnattr_setflags(&spawnAttrs, .init(POSIX_SPAWN_SETPGROUP)))
try _throwIfPosixError(posix_spawnattr_setflags(&spawnAttrs, .init(POSIX_SPAWN_CLOEXEC_DEFAULT)))
#else
var spawnAttrs: posix_spawnattr_t = posix_spawnattr_t()
#endif
try _throwIfPosixError(posix_spawnattr_init(&spawnAttrs))
try _throwIfPosixError(posix_spawnattr_setflags(&spawnAttrs, .init(POSIX_SPAWN_SETPGROUP)))

#if canImport(Darwin)
try _throwIfPosixError(posix_spawnattr_setflags(&spawnAttrs, .init(POSIX_SPAWN_CLOEXEC_DEFAULT)))
#else
// POSIX_SPAWN_CLOEXEC_DEFAULT is an Apple extension so emulate it.
for fd in 3 ... findMaximumOpenFD() {
guard adddup2[fd] == nil &&
Expand Down