-
Notifications
You must be signed in to change notification settings - Fork 1.2k
add Android shims for spawnattr #5301
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
base: main
Are you sure you want to change the base?
Conversation
|
@swift-ci please smoke test |
parkera
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably fine, but should we be looking at improving swift-subprocess instead, or in addition to this?
|
@parkera This PR is mostly motivated by being able to lower the recent Android SDK to API 24 instead of 28, which would currently fail to compile, because of these missing symbols on API 27 and below. I don't think people are going to use Process or subprocess a lot on Android, but at least this is better than removing it by "!os(Android)" You can read more about this discussion here: https://forums.swift.org/t/android-api-minimum-for-the-swift-sdk-for-android/82874 |
|
@swift-ci please smoke test |
1 similar comment
|
@swift-ci please smoke test |
|
@ktoso I am just trying to get building in my fork with Github Actions and the Android SDK, so no need to run the smoke tests. But thanks! |
|
I see lol, I'll stop then :-) |
|
So after a lot of debugging, I also found that the existing polyfills did not work on API 27 devices and below. After fixing those, I built a API 24 SDK with this PR, and the below code now correctly runs with no errors on both a API 24 device and API 28 @main
struct MyExecutable {
static func main() {
let executablePath = "/system/bin/ls"
let arguments = ["-l"]
let process = Process()
process.executableURL = URL(fileURLWithPath: executablePath)
process.arguments = arguments
let pipe = Pipe()
process.standardOutput = pipe
process.standardError = pipe
do {
try process.run()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
if let output = String(data: data, encoding: .utf8) {
print("--- Subprocess Output ---")
print(output)
print("-------------------------")
}
process.waitUntilExit()
print("Process exited with status: \(process.terminationStatus)")
} catch {
print("Failed to spawn process: \(error)")
}
}
} |
Adds shims for the posix_spawnattr added in #2928 for Android 27 and below.