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

os.write on a closed socket triggers SIGPIPE #5614

Open
truemedian opened this issue Jun 15, 2020 · 4 comments
Open

os.write on a closed socket triggers SIGPIPE #5614

truemedian opened this issue Jun 15, 2020 · 4 comments
Labels
standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@truemedian
Copy link
Contributor

Calling os.write() on a peer-closed socket without the MSG_NOSIGNAL flag triggers a SIGPIPE, rather than return an EPIPE errno.

@Vexu Vexu added the frontend Tokenization, parsing, AstGen, Sema, and Liveness. label Jun 16, 2020
@Vexu Vexu added this to the 0.7.0 milestone Jun 16, 2020
@Vexu Vexu added standard library This issue involves writing Zig code for the standard library. and removed frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Jun 16, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 17, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
@ghost
Copy link

ghost commented Oct 4, 2022

Would the right thing to do be to set MSG_NOSIGNAL by default on network sockets? I just ran into this, seems like a horrible default behavior to have a network program exit without any message when the remote end closes

@IridescentRose
Copy link
Sponsor Contributor

Correct, the best thing to do by default on network sockets is MSG_NOSIGNAL

@ghost
Copy link

ghost commented Nov 5, 2022

I was asking if the stdlib should set it automatically, but I just realized it seems to be Linux-specific... there seems to be no equivalent to the MSG constants on windows for example.

@truemedian
Copy link
Contributor Author

truemedian commented Nov 5, 2022

Windows doesn't have SIGPIPE. It does the equivalent of MSG_NOSIGNAL and returns the windows version of EPIPE (BROKEN_PIPE).

This doesn't break on windows because it doesn't need to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
standard library This issue involves writing Zig code for the standard library.
Projects
None yet
4 participants