-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Stabilize #[unix_sigpipe = "sig_dfl"]
on fn main()
#120832
Conversation
r? @davidtwco rustbot has assigned @davidtwco. Use r? to explicitly pick a reviewer |
This comment has been minimized.
This comment has been minimized.
4be319b
to
775ee4e
Compare
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.
Implementation looks good to me, will wait for the t-lang nomination.
I do think we should stabilize "inherit". In particular, if we consider changing the default in a future edition, I'd propose changing the default to "inherit", not to "sig_dfl", so that we don't make the syscall at all. |
I've mentioned in the forum that I'm missing an option to ignore both the signal and panic-causing errors in println. If this attribute wasn't so transparent with low-level unix jargon, maybe it could be used to set the third strategy? |
I don't think we should stabilize
Maybe we don't even need So maybe we need to make a decision on #62569 after all, before we can stabilize anything. Perhaps summarizing #62569 into an RFC is the best way forward here. I think it is, and I hope to get around to it in a not too distant future.
I replied to your post in the forum. In short: I don't think |
@Enselic What's the harm in stabilizing We allow people to write |
☔ The latest upstream changes (presumably #120881) made this pull request unmergeable. Please resolve the merge conflicts. |
@joshtriplett It is possible I am overestimating the harm of stabilizing an attribute that might not be needed long term. 10 years from now I just think it will be annoying to have to maintain an attribute variant that is not needed. It unnecessarily restricts us. If we can find a way to turn I also think that "no attribute used" is a good way to convey "no special code runs". If we want to stabilize
so I don't think "inherit" is a slam-dunk name to use in our case, because the "inherit" mechanism has already been applied when the Rust Maybe |
Maybe change the default on edition boundary, and only support a Boolean attribute that restores the old behavior for |
If we stabilize inherit and skip stabilizing dfl, then people who want dfl can explicitly make the call in main themselves. And then you can remove the dfl option altogether and get your lto win. If we don’t stabilize inherit, then people who want standard UNIX behavior have no way to get it, other than wait for an unspecified new edition, I guess? Which in reality is another 3 years away, at least? |
Discussed in today's @rust-lang/libs meeting: libs does not consider ourselves a blocker for this stabilization. |
…r=davidtwco unix_sigpipe: Simple fixes and improvements in tests In rust-lang#120832 I included 5 preparatory commits. It will take a while before discussions there and in rust-lang#62569 is settled, so here is a PR that splits out 4 of the commits that are easy to review, to get them out of the way. r? `@davidtwco` who already approved these commits in rust-lang#120832 (but I have tweaked them a bit and rebased them since then). For the convenience of my reviewer, here are the full commit messages of the commits: <details> <summary>Click to expand</summary> ``` commit 948b1d6 (HEAD -> unix_sigpipe-tests-fixes, origin/unix_sigpipe-tests-fixes) Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 07:57:27 2024 +0100 tests: Add unix_sigpipe-different-duplicates.rs test variant To make sure that #[unix_sigpipe = "x"] #[unix_sigpipe = "y"] behaves like #[unix_sigpipe = "x"] #[unix_sigpipe = "x"] commit d14f158 Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 08:47:47 2024 +0100 tests: Combine unix_sigpipe-not-used.rs and unix_sigpipe-only-feature.rs The only difference between the files is the presence/absence of #![feature(unix_sigpipe)] attribute. Avoid duplication by using revisions instead. commit a1cb3db Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 06:44:56 2024 +0100 tests: Rename unix_sigpipe.rs to unix_sigpipe-bare.rs for clarity The test is for the "bare" variant of the attribute that looks like this: #[unix_sigpipe] which is not allowed, because it must look like this: #[unix_sigpipe = "sig_ign"] commit e060274 Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 05:48:24 2024 +0100 tests: Fix typo unix_sigpipe-error.rs -> unix_sigpipe-sig_ign.rs There is no error expected. It's simply the "regular" test for sig_ign. So rename it. ``` </details> Tracking issue: rust-lang#97889
…r=davidtwco unix_sigpipe: Simple fixes and improvements in tests In rust-lang#120832 I included 5 preparatory commits. It will take a while before discussions there and in rust-lang#62569 is settled, so here is a PR that splits out 4 of the commits that are easy to review, to get them out of the way. r? ``@davidtwco`` who already approved these commits in rust-lang#120832 (but I have tweaked them a bit and rebased them since then). For the convenience of my reviewer, here are the full commit messages of the commits: <details> <summary>Click to expand</summary> ``` commit 948b1d6 (HEAD -> unix_sigpipe-tests-fixes, origin/unix_sigpipe-tests-fixes) Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 07:57:27 2024 +0100 tests: Add unix_sigpipe-different-duplicates.rs test variant To make sure that #[unix_sigpipe = "x"] #[unix_sigpipe = "y"] behaves like #[unix_sigpipe = "x"] #[unix_sigpipe = "x"] commit d14f158 Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 08:47:47 2024 +0100 tests: Combine unix_sigpipe-not-used.rs and unix_sigpipe-only-feature.rs The only difference between the files is the presence/absence of #![feature(unix_sigpipe)] attribute. Avoid duplication by using revisions instead. commit a1cb3db Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 06:44:56 2024 +0100 tests: Rename unix_sigpipe.rs to unix_sigpipe-bare.rs for clarity The test is for the "bare" variant of the attribute that looks like this: #[unix_sigpipe] which is not allowed, because it must look like this: #[unix_sigpipe = "sig_ign"] commit e060274 Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 05:48:24 2024 +0100 tests: Fix typo unix_sigpipe-error.rs -> unix_sigpipe-sig_ign.rs There is no error expected. It's simply the "regular" test for sig_ign. So rename it. ``` </details> Tracking issue: rust-lang#97889
…r=davidtwco unix_sigpipe: Simple fixes and improvements in tests In rust-lang#120832 I included 5 preparatory commits. It will take a while before discussions there and in rust-lang#62569 is settled, so here is a PR that splits out 4 of the commits that are easy to review, to get them out of the way. r? ```@davidtwco``` who already approved these commits in rust-lang#120832 (but I have tweaked them a bit and rebased them since then). For the convenience of my reviewer, here are the full commit messages of the commits: <details> <summary>Click to expand</summary> ``` commit 948b1d6 (HEAD -> unix_sigpipe-tests-fixes, origin/unix_sigpipe-tests-fixes) Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 07:57:27 2024 +0100 tests: Add unix_sigpipe-different-duplicates.rs test variant To make sure that #[unix_sigpipe = "x"] #[unix_sigpipe = "y"] behaves like #[unix_sigpipe = "x"] #[unix_sigpipe = "x"] commit d14f158 Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 08:47:47 2024 +0100 tests: Combine unix_sigpipe-not-used.rs and unix_sigpipe-only-feature.rs The only difference between the files is the presence/absence of #![feature(unix_sigpipe)] attribute. Avoid duplication by using revisions instead. commit a1cb3db Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 06:44:56 2024 +0100 tests: Rename unix_sigpipe.rs to unix_sigpipe-bare.rs for clarity The test is for the "bare" variant of the attribute that looks like this: #[unix_sigpipe] which is not allowed, because it must look like this: #[unix_sigpipe = "sig_ign"] commit e060274 Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 05:48:24 2024 +0100 tests: Fix typo unix_sigpipe-error.rs -> unix_sigpipe-sig_ign.rs There is no error expected. It's simply the "regular" test for sig_ign. So rename it. ``` </details> Tracking issue: rust-lang#97889
…r=davidtwco unix_sigpipe: Simple fixes and improvements in tests In rust-lang#120832 I included 5 preparatory commits. It will take a while before discussions there and in rust-lang#62569 is settled, so here is a PR that splits out 4 of the commits that are easy to review, to get them out of the way. r? `@davidtwco` who already approved these commits in rust-lang#120832 (but I have tweaked them a bit and rebased them since then). For the convenience of my reviewer, here are the full commit messages of the commits: <details> <summary>Click to expand</summary> ``` commit 948b1d6 (HEAD -> unix_sigpipe-tests-fixes, origin/unix_sigpipe-tests-fixes) Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 07:57:27 2024 +0100 tests: Add unix_sigpipe-different-duplicates.rs test variant To make sure that #[unix_sigpipe = "x"] #[unix_sigpipe = "y"] behaves like #[unix_sigpipe = "x"] #[unix_sigpipe = "x"] commit d14f158 Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 08:47:47 2024 +0100 tests: Combine unix_sigpipe-not-used.rs and unix_sigpipe-only-feature.rs The only difference between the files is the presence/absence of #![feature(unix_sigpipe)] attribute. Avoid duplication by using revisions instead. commit a1cb3db Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 06:44:56 2024 +0100 tests: Rename unix_sigpipe.rs to unix_sigpipe-bare.rs for clarity The test is for the "bare" variant of the attribute that looks like this: #[unix_sigpipe] which is not allowed, because it must look like this: #[unix_sigpipe = "sig_ign"] commit e060274 Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 05:48:24 2024 +0100 tests: Fix typo unix_sigpipe-error.rs -> unix_sigpipe-sig_ign.rs There is no error expected. It's simply the "regular" test for sig_ign. So rename it. ``` </details> Tracking issue: rust-lang#97889
…r=davidtwco unix_sigpipe: Simple fixes and improvements in tests In rust-lang#120832 I included 5 preparatory commits. It will take a while before discussions there and in rust-lang#62569 is settled, so here is a PR that splits out 4 of the commits that are easy to review, to get them out of the way. r? ``@davidtwco`` who already approved these commits in rust-lang#120832 (but I have tweaked them a bit and rebased them since then). For the convenience of my reviewer, here are the full commit messages of the commits: <details> <summary>Click to expand</summary> ``` commit 948b1d6 (HEAD -> unix_sigpipe-tests-fixes, origin/unix_sigpipe-tests-fixes) Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 07:57:27 2024 +0100 tests: Add unix_sigpipe-different-duplicates.rs test variant To make sure that #[unix_sigpipe = "x"] #[unix_sigpipe = "y"] behaves like #[unix_sigpipe = "x"] #[unix_sigpipe = "x"] commit d14f158 Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 08:47:47 2024 +0100 tests: Combine unix_sigpipe-not-used.rs and unix_sigpipe-only-feature.rs The only difference between the files is the presence/absence of #![feature(unix_sigpipe)] attribute. Avoid duplication by using revisions instead. commit a1cb3db Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 06:44:56 2024 +0100 tests: Rename unix_sigpipe.rs to unix_sigpipe-bare.rs for clarity The test is for the "bare" variant of the attribute that looks like this: #[unix_sigpipe] which is not allowed, because it must look like this: #[unix_sigpipe = "sig_ign"] commit e060274 Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 05:48:24 2024 +0100 tests: Fix typo unix_sigpipe-error.rs -> unix_sigpipe-sig_ign.rs There is no error expected. It's simply the "regular" test for sig_ign. So rename it. ``` </details> Tracking issue: rust-lang#97889
Rollup merge of rust-lang#121527 - Enselic:unix_sigpipe-tests-fixes, r=davidtwco unix_sigpipe: Simple fixes and improvements in tests In rust-lang#120832 I included 5 preparatory commits. It will take a while before discussions there and in rust-lang#62569 is settled, so here is a PR that splits out 4 of the commits that are easy to review, to get them out of the way. r? ``@davidtwco`` who already approved these commits in rust-lang#120832 (but I have tweaked them a bit and rebased them since then). For the convenience of my reviewer, here are the full commit messages of the commits: <details> <summary>Click to expand</summary> ``` commit 948b1d6 (HEAD -> unix_sigpipe-tests-fixes, origin/unix_sigpipe-tests-fixes) Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 07:57:27 2024 +0100 tests: Add unix_sigpipe-different-duplicates.rs test variant To make sure that #[unix_sigpipe = "x"] #[unix_sigpipe = "y"] behaves like #[unix_sigpipe = "x"] #[unix_sigpipe = "x"] commit d14f158 Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 08:47:47 2024 +0100 tests: Combine unix_sigpipe-not-used.rs and unix_sigpipe-only-feature.rs The only difference between the files is the presence/absence of #![feature(unix_sigpipe)] attribute. Avoid duplication by using revisions instead. commit a1cb3db Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 06:44:56 2024 +0100 tests: Rename unix_sigpipe.rs to unix_sigpipe-bare.rs for clarity The test is for the "bare" variant of the attribute that looks like this: #[unix_sigpipe] which is not allowed, because it must look like this: #[unix_sigpipe = "sig_ign"] commit e060274 Author: Martin Nordholts <martin.nordholts@codetale.se> Date: Fri Feb 9 05:48:24 2024 +0100 tests: Fix typo unix_sigpipe-error.rs -> unix_sigpipe-sig_ign.rs There is no error expected. It's simply the "regular" test for sig_ign. So rename it. ``` </details> Tracking issue: rust-lang#97889
That is the variant that has the highest potential to be stabilized, and we want to test it as much as possible.
The attribute is used like this: #[unix_sigpipe = "sig_dfl"] fn main() { // ... } When used, `SIGPIPE` will be set to `SIG_DFL` before `fn main()` is invoked, rather than being set to `SIG_IGN` which is the default. This commit does NOT stabilize `#[unix_sigpipe = "sig_ign"]` or `#[unix_sigpipe = "inherit"]`. See the PR for more info.
775ee4e
to
b6d7e9d
Compare
Rebased to resolve conflicts. Current status: If we decide not to change the default If we want to change the default We can't stabilize We can't stabilize |
On behalf of the Edition 2024 Working Group, even though our soft deadline for accepting editions changes has passed, we're still willing to entertain changing the SIGPIPE default in the 2024 edition, but the hard deadline for the edition cutoff is the end of May, so please make a decision promptly. :) |
As someone who writes a lot of software that works by connecting things up with pipes: I strongly encourage at least getting After reading around in 62569, I understand better now some of the concerns around changing the Rust signal-handling default behavior. While as a UNIX-style command-line tool dev I'd much rather not have been surprised by this difference from other development environments on UNIX, it was not that hard to find out where the surprise was coming from and to resolve it. Except, that is, for the fact that it's locked me into using nightly for basically all of my Rust development ever. That's really my only beef: it's been years, and I'm still using nightly just for this. So change the default for edition 2024 or don't... but please, please, at least make it possible for developers of UNIX pipe-based tools to use stable instead of having to take on nightly just to get back to their operating system's default behavior. |
As a completely separate concern from what to do about the default behavior, I have some concerns about the attribute syntax itself. Currently, the attribute describes the syscall that is being performed (setting the signal disposition for SIGPIPE), but this is a very low-level API that may be confusing to people not familiar with the weeds of UNIX pipes. Additionally, I believe that the attribute should instead describe what it is actually achieving: in this case, changing the behavior of the program when a pipe is broken. Proposed syntax: Possible values for the attribute would be:
|
☔ The latest upstream changes (presumably #122312) made this pull request unmergeable. Please resolve the merge conflicts. |
…idtwco unix_sigpipe: Replace `inherit` with `sig_dfl` in syntax tests The `sig_dfl` variant of the attribute is the most likely variant to be stabilized first, and thus to become the "most allowed" variant of the attribute. Because of this, it is the most appropriate variant to use in syntax tests, because even if the most allowed variant is used, the compiler shall still emit errors if it e.g. is used in the wrong places. r? `@davidtwco` who already [approved ](rust-lang#120832 (review)) this commit in rust-lang#120832. It would be nice to land the last preparatory commit of that PR before we begin to [rename ](rust-lang#120832 (comment)) things which will of course create a lot of code conflicts.
…idtwco unix_sigpipe: Replace `inherit` with `sig_dfl` in syntax tests The `sig_dfl` variant of the attribute is the most likely variant to be stabilized first, and thus to become the "most allowed" variant of the attribute. Because of this, it is the most appropriate variant to use in syntax tests, because even if the most allowed variant is used, the compiler shall still emit errors if it e.g. is used in the wrong places. r? ``@davidtwco`` who already [approved ](rust-lang#120832 (review)) this commit in rust-lang#120832. It would be nice to land the last preparatory commit of that PR before we begin to [rename ](rust-lang#120832 (comment)) things which will of course create a lot of code conflicts.
Rollup merge of rust-lang#122328 - Enselic:sig_dfl-not-inherit, r=davidtwco unix_sigpipe: Replace `inherit` with `sig_dfl` in syntax tests The `sig_dfl` variant of the attribute is the most likely variant to be stabilized first, and thus to become the "most allowed" variant of the attribute. Because of this, it is the most appropriate variant to use in syntax tests, because even if the most allowed variant is used, the compiler shall still emit errors if it e.g. is used in the wrong places. r? ``@davidtwco`` who already [approved ](rust-lang#120832 (review)) this commit in rust-lang#120832. It would be nice to land the last preparatory commit of that PR before we begin to [rename ](rust-lang#120832 (comment)) things which will of course create a lot of code conflicts.
unix_sigpipe: Replace `inherit` with `sig_dfl` in syntax tests The `sig_dfl` variant of the attribute is the most likely variant to be stabilized first, and thus to become the "most allowed" variant of the attribute. Because of this, it is the most appropriate variant to use in syntax tests, because even if the most allowed variant is used, the compiler shall still emit errors if it e.g. is used in the wrong places. r? ``@davidtwco`` who already [approved ](rust-lang/rust#120832 (review)) this commit in rust-lang/rust#120832. It would be nice to land the last preparatory commit of that PR before we begin to [rename ](rust-lang/rust#120832 (comment)) things which will of course create a lot of code conflicts.
I'm worried that stabilizing this attribute makes |
I will look into ways of removing the This means stabilization of this attribute will not happen near term, so I will close this PR for now. Thanks all for the feedback 👍 |
Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...` In the stabilization [attempt](rust-lang#120832) of `#[unix_sigpipe = "sig_dfl"]`, a concern was [raised ](rust-lang#120832 (comment)) related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was [also raised](rust-lang#120832 (comment)), namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization. Tracking issue: rust-lang#97889
Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...` In the stabilization [attempt](rust-lang#120832) of `#[unix_sigpipe = "sig_dfl"]`, a concern was [raised ](rust-lang#120832 (comment)) related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was [also raised](rust-lang#120832 (comment)), namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization. Tracking issue: rust-lang#97889
Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...` In the stabilization [attempt](rust-lang#120832) of `#[unix_sigpipe = "sig_dfl"]`, a concern was [raised ](rust-lang#120832 (comment)) related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was [also raised](rust-lang#120832 (comment)), namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization. Tracking issue: rust-lang#97889
Rollup merge of rust-lang#124480 - Enselic:on-broken-pipe, r=jieyouxu Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...` In the stabilization [attempt](rust-lang#120832) of `#[unix_sigpipe = "sig_dfl"]`, a concern was [raised ](rust-lang#120832 (comment)) related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was [also raised](rust-lang#120832 (comment)), namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization. Tracking issue: rust-lang#97889
Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...` In the stabilization [attempt](rust-lang/rust#120832) of `#[unix_sigpipe = "sig_dfl"]`, a concern was [raised ](rust-lang/rust#120832 (comment)) related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was [also raised](rust-lang/rust#120832 (comment)), namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization. Tracking issue: rust-lang/rust#97889
Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...` In the stabilization [attempt](rust-lang/rust#120832) of `#[unix_sigpipe = "sig_dfl"]`, a concern was [raised ](rust-lang/rust#120832 (comment)) related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was [also raised](rust-lang/rust#120832 (comment)), namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization. Tracking issue: rust-lang/rust#97889
I would like to propose that we stabilize
#[unix_sigpipe = "sig_dfl"]
.This PR does that.
By my estimation, merging this PR will close #46016.
Tracking issue is #97889.
Stabilization report
The
#[unix_sigpipe = "sig_dfl"]
attribute has been available in nightly sincenightly-2022-09-04
(17 months).It is being used by rustc and rustdoc themselves, and also by third party code (1, 2).
I have monitored the keyword
sigpipe
onrust-lang/rust
during all this time, and no problems have been reported regarding the attribute. To the contrary. It's infrastructure was used to implement a bugfix in a backwards compatible way.Summary and examples
Everything you need to know about the stabilized attribute should be documented in the reference. PR. Rendered.
Test cases
https://github.com/rust-lang/rust/tree/master/tests/ui/attributes/unix_sigpipe
Edge cases
None that I am aware of.
Note that using
#[unix_sigpipe = "sig_dfl"]
and receiving aSIGPIPE
means destructors will not run since the process will be immediately killed. I documented this in The Reference.Unresolved questions
None. See tracking issue.
Worth noting
This PR does NOT stabilize any other variant of the attribute, namely
#[unix_sigpipe = "sig_ign"]
and#[unix_sigpipe = "inherit"]
.There are many reasons for this:
SIGPIPE
be the default (SIG_IGN
) and explicitly setting it toSIG_IGN
with#[unix_sigpipe = "sig_ign"]
#[unix_sigpipe = "sig_ign"]
nor#[unix_sigpipe = "inherit"]
in the wild, so they are much less tested, and there seems to be no desire for them.fn lang_start()
sigpipe
arg fromu8
tobool
("not set" or "set to sig_dfl"), enabling better lto. Only relevant if we end up deciding not to change the default, and not adding#[unix_sigpipe = "inherit"]
.Potential future work
There is a discussion about changing the default
SIGPIPE
handler. See here. Changing the default would likely require us to also stabilize#[unix_sigpipe = "sig_ign"]
. But doing that and discussing changing the default is out of scope of this PR.Left to do
unix_sigpipe
if we merge this.FCP
Since we can't close the tracking issue entirely yet, my hope is that we can do an FCP on this PR rather than on the tracking issue.