Closed jakepetroules closed 1 month ago
@swift-ci please test linux
@swift-ci please test windows
Also opened #5095 for release/6.0.2 to ensure this makes it into 6.0.2
@jakepetroules This appears to have broken this bot: https://ci.swift.org/job/oss-swift-6.0-package-static-sdk/78/
/home/build-user/source/swift-project/swift-corelibs-foundation/Sources/CoreFoundation/CFPlatform.c:2302:10: error: call to undeclared function 'posix_spawn_file_actions_addchdir'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
2302 | return posix_spawn_file_actions_addchdir((posix_spawn_file_actions_t *)file_actions, path);
| ^
/home/build-user/source/swift-project/swift-corelibs-foundation/Sources/CoreFoundation/CFPlatform.c:2302:10: note: did you mean 'posix_spawn_file_actions_addchdir_np'?
/home/build-user/build/sdk_root/x86_64/usr/include/spawn.h:74:5: note: 'posix_spawn_file_actions_addchdir_np' declared here
74 | int posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t *__restrict, const char *__restrict);
| ^
1 error generated.
posix_spawn_file_actions_addchdir_np is the official way to set the working directory of a spawned process and is supported on both macOS and glibc (Linux, etc.). This makes Process.currentDirectoryURL thread-safe, as the current approach will result in the working directory being nondeterministically assigned when spawning processes across multiple threads, using different working directories.
This already landed in main via https://github.com/swiftlang/swift-corelibs-foundation/pull/4981 (and amendment in https://github.com/swiftlang/swift-corelibs-foundation/pull/5090) and it's pretty disruptive for us so I'd like to get it into 6.0.x if possible.