|
| 1 | +From 49dac2443c37c2bff59c9294c096b2948cace43b Mon Sep 17 00:00:00 2001 |
| 2 | +From: Anton Pogonets <apogonets@readdle.com> |
| 3 | +Date: Fri, 9 Apr 2021 13:38:14 +0300 |
| 4 | +Subject: [PATCH] Dont use posix_spawnattr on Android. It available only from |
| 5 | + API>=28 |
| 6 | + |
| 7 | +--- |
| 8 | + Sources/Foundation/Process.swift | 6 +++++- |
| 9 | + 1 file changed, 5 insertions(+), 1 deletion(-) |
| 10 | + |
| 11 | +diff --git a/Sources/Foundation/Process.swift b/Sources/Foundation/Process.swift |
| 12 | +index 7d6a1a39..cfe4cd19 100644 |
| 13 | +--- a/Sources/Foundation/Process.swift |
| 14 | ++++ b/Sources/Foundation/Process.swift |
| 15 | +@@ -950,6 +950,8 @@ open class Process: NSObject, @unchecked Sendable { |
| 16 | + ]) |
| 17 | + } |
| 18 | + #endif |
| 19 | ++ |
| 20 | ++#if !os(Android) |
| 21 | + try _throwIfPosixError(posix_spawnattr_init(&spawnAttrs)) |
| 22 | + try _throwIfPosixError(posix_spawnattr_setflags(&spawnAttrs, .init(POSIX_SPAWN_SETPGROUP))) |
| 23 | + #if canImport(Darwin) |
| 24 | +@@ -964,6 +966,7 @@ open class Process: NSObject, @unchecked Sendable { |
| 25 | + } |
| 26 | + try _throwIfPosixError(_CFPosixSpawnFileActionsAddClose(fileActions, fd)) |
| 27 | + } |
| 28 | ++#endif |
| 29 | + #endif |
| 30 | + |
| 31 | + // Unsafe fallback for systems missing posix_spawn_file_actions_addchdir[_np] |
| 32 | +@@ -995,8 +998,9 @@ open class Process: NSObject, @unchecked Sendable { |
| 33 | + throw _NSErrorWithErrno(errno, reading: true, path: launchPath) |
| 34 | + } |
| 35 | + }) |
| 36 | ++#if !os(Android) |
| 37 | + posix_spawnattr_destroy(&spawnAttrs) |
| 38 | +- |
| 39 | ++#endif |
| 40 | + // Close the write end of the input and output pipes. |
| 41 | + if let pipe = standardInput as? Pipe { |
| 42 | + pipe.fileHandleForReading.closeFile() |
| 43 | +-- |
| 44 | +2.46.0 |
| 45 | + |
0 commit comments