apple / swift-corelibs-foundation

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

Add a thread-safe implementation of Process.currentDirectoryURL #4981

Open jakepetroules opened 2 weeks ago

jakepetroules commented 2 weeks 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.

jakepetroules commented 2 weeks ago

@swift-ci please test