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

posix_spawn: Don't attempt to dup2 identical fds #214

Merged
merged 1 commit into from
Jul 28, 2021

Conversation

bgamari
Copy link
Contributor

@bgamari bgamari commented Jul 27, 2021

Editorial note: @snoyberg, I'd like to again apologize for how many iterations this posix_spawn work has required; it really has been a compatibility nightmare. This particular issue remained under the radar in my Darwin testing on GHC as I had chalked it up to a GHC bug, having seen the same test fail for reasons unrelated to process. Sadly, this time the failure is actually due to a bug in Darwin's posix_spawn_file_actions_adddup2 implementation. Thanks again, for your patience.

macOS Big Sur does not allow the user to posix_spawn_file_actions_adddup2 an
fd to itself. Instead of behaving as a no-op as specified by POSIX
2017.1 (and as done by every other operating system), it instead fails with
EBADFD in posix_spawn. This caused a single tricky-to-identify
failure in GHC's testsuite.

macOS Big Sur does not allow the user to `posix_spawn_file_actions_adddup2` an
fd to itself. Instead of behaving as a no-op as specified by POSIX
2017.1 (and done by every other operating system), it instead fails with
`EBADFD` in `posix_spawn`. This caused a single tricky-to-identify
failure in GHC's testsuite.
@bgamari bgamari force-pushed the wip/darwin-dup2-fix branch from b6728c2 to 5a42f02 Compare July 27, 2021 19:36
return -1;
}
// N.B. POSIX specifies that dup2(x,x) should be a no-op, but
// naturally Apple ignores this and rather fails in posix_spawn on Big
Copy link
Collaborator

Choose a reason for hiding this comment

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

You have all my sympathies @bgamari

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.

2 participants