-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Support #[unix_sigpipe = "inherit|sig_dfl"]
on fn main()
to prevent ignoring SIGPIPE
#97802
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ddee45e
Support `#[unix_sigpipe = "inherit|sig_dfl|sig_ign"]` on `fn main()`
Enselic 6eae169
unix_sigpipe: Skip some tests on android; libc has no `signal` function
Enselic 236903f
unix_sigpipe: Inline compiler sigpipe constants in std
Enselic 3d1a4e4
unix_sigpipe: Add docs for `init()` `sigpipe` param
Enselic 3810d4a
unix_sigpipe: Make `sigpipe` param docs long-form
Enselic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//! NOTE: Keep these constants in sync with `library/std/src/sys/unix/mod.rs`! | ||
|
||
/// Do not touch `SIGPIPE`. Use whatever the parent process uses. | ||
#[allow(dead_code)] | ||
pub const INHERIT: u8 = 1; | ||
|
||
/// Change `SIGPIPE` to `SIG_IGN` so that failed writes results in `EPIPE` | ||
/// that are eventually converted to `ErrorKind::BrokenPipe`. | ||
#[allow(dead_code)] | ||
pub const SIG_IGN: u8 = 2; | ||
|
||
/// Change `SIGPIPE` to `SIG_DFL` so that the process is killed when trying | ||
/// to write to a closed pipe. This is usually the desired behavior for CLI | ||
/// apps that produce textual output that you want to pipe to other programs | ||
/// such as `head -n 1`. | ||
#[allow(dead_code)] | ||
pub const SIG_DFL: u8 = 3; | ||
|
||
/// `SIG_IGN` has been the Rust default since 2014. See | ||
/// <https://github.com/rust-lang/rust/issues/62569>. | ||
#[allow(dead_code)] | ||
pub const DEFAULT: u8 = SIG_IGN; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to have a comment here explaining the new argument (since unlike the other two it is not standard).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When just reading this file that comment remains rather mysterious though -- there are 256 possible values for
sigpipe
and it is unclear what they would all mean.Looks like the concrete meaning is platform-dependent? That should be said, maybe with a reference to the file where unix defines its meanings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah no actually compiler/rustc_session/src/config/sigpipe.rs is not target-dependent. So that should probably be referenced.
But then I don't understand why the std version of that file is inside
unix
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RalfJung If you would like to have more of a "full context" kind of doc at this location, that's perfectly fine with me. Would you mind us iterating the exact contents of that comment via GitHub comments rather than commits though?
Here is my proposal on what we could write here:
I propose that we do not duplicate this comment also in
library/std/src/sys/unix/mod.rs
though, i.e. that we only put that comment at the location you made this comment.Looking forward to your response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that sounds good! I don't have a strong preference whether library/std/src/rt.rs points to library/std/src/sys/unix/mod.rs or vice versa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Commit pushed.