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

fix: posix_spawn returns errno on error, not -1 #2595

Merged
merged 2 commits into from
Feb 2, 2025

Conversation

SteveLauC
Copy link
Member

What does this PR do

According to the POSIX man page:

Otherwise, no child process shall be created, the value stored into the variable pointed to by a non-NULL pid is unspecified, and an error number shall be returned as the function return value to indicate the error.

Error::result() assumes the function returns -1 on error, so it won't work here.

Actually, this is my fault 🤦‍♂️, the implementation in PR #2007 handled this correctly, but my erroneous review comment led the PR in the wrong direction.

Also, since posix_spawn() uses fork() (can be other syscalls depending on the impl) under the hood, its tests should grab the FORK_MTX lock.

Checklist:

  • I have read CONTRIBUTING.md
  • I have written necessary tests and rustdoc comments
  • A change log has been added if this PR modifies nix's API

These 2 posx_spawn*() interfaces have not been released, so no changelog needed.

@SteveLauC SteveLauC marked this pull request as ready for review February 2, 2025 12:34
@SteveLauC SteveLauC added this pull request to the merge queue Feb 2, 2025
Merged via the queue into nix-rust:master with commit 0c40b8d Feb 2, 2025
37 checks passed
@SteveLauC SteveLauC deleted the fix/posix_spawn_return_value branch February 2, 2025 13:01
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.

1 participant