Skip to content
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

Figure out how to set the working directory for spawned processes on all platforms #1271

Open
ahoppen opened this issue May 9, 2024 · 1 comment

Comments

@ahoppen
Copy link
Collaborator

ahoppen commented May 9, 2024

Amazon Linux 2 and CentOS 7 have a glibc that doesn’t support posix_spawn_file_actions_addchdir_np and thus TSCBasic.Process can’t launch a process on these platforms with the working directory set. We currently fall back to launching the index tasks without a working directory on these platforms, which I think is fine because SwiftPM gives us compiler arguments with absolute paths. But we should figure something out.

Using Foundation.Process is not an option because it runs chdir on the current process for Posix platforms, which is racy if there are multiple subprocesses being spawned simultaneously. On Windows TSCBasic.Processs uses Foundation.Process and Foundation.Process properly set the working directory of the subprocesses on Windows, so Windows is not a problem.

ahoppen added a commit to ahoppen/sourcekit-lsp that referenced this issue May 9, 2024
Details from apple#1271

> Amazon Linux 2 and CentOS 7 have a glibc that doesn’t support `posix_spawn_file_actions_addchdir_np` and thus `TSCBasic.Process` can’t launch a process on these platforms with the working directory set. We currently fall back to launching the index tasks without a working directory on these platforms, which I think is fine because SwiftPM gives us compiler arguments with absolute paths. But we should figure something out.
>
> Using `Foundation.Process` is not an option because it runs `chdir` on the current process for Posix platforms, which is racy if there are multiple subprocesses being spawned simultaneously. On Windows `TSCBasic.Processs` uses `Foundation.Process` and `Foundation.Process` properly set the working directory of the subprocesses on Windows, so Windows is not a problem.

rdar://127797048
@ahoppen
Copy link
Collaborator Author

ahoppen commented May 13, 2024

Synced to Apple’s issue tracker as rdar://128016626

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant