Skip to content

CDRIVER-3823 ignore SIGPIPE on osx #716

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

Merged
merged 2 commits into from
Jan 8, 2021

Conversation

samantharitter
Copy link
Contributor

MSG_NOSIGNAL, the flag that we currently use to ignore SIGPIPE on POSIX systems, is not supported on OSX. Instead, OSX offers the SO_NOSIGPIPE flag that can be set as a socket option before performing writes.

I had asked @kmahar to test a different solution for ignoring SIGPIPE:
signal(SIGPIPE, SIG_IGN);

Upon further research, this solution isn't ideal, because it ignores SIGPIPE for the entire program, including any user code running a level above the C driver. In the case that a user is interested in SIGPIPE for some reason, setting the handler to SIG_IGN like this would also capture SIGPIPE in user code. The SO_NOSIGPIPE solution is less intrusive for a library like ours.

Copy link
Contributor

@kmahar kmahar left a comment

Choose a reason for hiding this comment

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

this fixes the crash! thanks for fixing this, should make our macOS Evergreen tests a lot more reliable 🙂

Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

Awesome, nice investigative work! I'm surprised we hadn't hit this before.
And I agree that this is better as a socket option instead of process-wide, so we do not interfere with existing signal handlers.

@samantharitter samantharitter merged commit 6f423a4 into mongodb:master Jan 8, 2021
kevinAlbs pushed a commit that referenced this pull request Feb 1, 2021
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