swiftlang / swift-corelibs-foundation

The Foundation Project, providing core utilities, internationalization, and OS independence
swift.org
Apache License 2.0
5.29k stars 1.14k forks source link

[6.0.2] Add a thread-safe implementation of Process.currentDirectoryURL #5095

Closed jakepetroules closed 1 month ago

jakepetroules commented 1 month ago

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 #4981 (and amendment in #5090) and it's pretty disruptive for us so I'd like to get it into 6.0.2 if possible.

jakepetroules commented 1 month ago

@swift-ci please test linux

jakepetroules commented 1 month ago

@swift-ci please test windows

jakepetroules commented 1 month ago

Also opened #5096 for release/6.0 to ensure this makes it into 6.0.3+