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

[std] Support cwd in Posix.Popen. #231

Merged
merged 1 commit into from
May 16, 2024
Merged

[std] Support cwd in Posix.Popen. #231

merged 1 commit into from
May 16, 2024

Conversation

beauby
Copy link
Contributor

@beauby beauby commented May 16, 2024

This commit enables setting the child process' cwd when calling Posix.Popen::create{}/System.popen{}.

This commit enables setting the child process' cwd when calling
`Posix.Popen::create{}`/`System.popen{}`.
@gregsexton
Copy link
Contributor

LGTM

@beauby beauby merged commit 4b5834d into SkipLabs:main May 16, 2024
4 checks passed
@beauby beauby deleted the popen-cwd branch May 16, 2024 09:39
Comment on lines +281 to +287
// NOTE: Since `posix_spawn()` does not provide a way for changing the
// working directory of the child process, we rely on GNU env.
cwd match {
| Some(path) -> !args = Array["env", "-C", path].concat(args)
| None() -> void
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use posix_spawn_file_actions_addchdir I guess? This makes me think it would be better to give up on posix_spawn and just use (v)fork/exec so that we can chdir and whatever else is needed in the child between fork and exec. Wrapping the whole thing in env is just a heavy-weight version of that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah at this stage posix_spawn_file_actions_addchdir_np is a non-standard extension. I agree that posix_spawn is a bit too limiting for our use, and that we should move to (v)fork/exec. I'll open an issue.

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

Successfully merging this pull request may close these issues.

3 participants