Skip to content

Fixes to ExitStatus and its docs #82411

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 7 commits into from
Mar 10, 2021
Merged

Conversation

ijackson
Copy link
Contributor

  • On Unix, properly display every possible wait status (and don't panic on weird values)
  • In the documentation, be clear and consistent about "exit status" vs "wait status".

Currently, on Nightly, this panics:

```
use std::process::ExitStatus;
use std::os::unix::process::ExitStatusExt;

fn main() {
    let st = ExitStatus::from_raw(0x007f);
    println!("st = {}", st);
}
```

This is because the impl of Display assumes that if .code() is None,
.signal() must be Some.  That was a false assumption, although it was
true with buggy code before
  5b1316f
  unix ExitStatus: Do not treat WIFSTOPPED as WIFSIGNALED

This is not likely to have affected many people in practice, because
`Command` will never produce such a wait status (`ExitStatus`).

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
@rust-highfive
Copy link
Contributor

r? @dtolnay

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 22, 2021
@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

LGTM once the tidy failure is resolved. Thanks!

@rust-log-analyzer

This comment has been minimized.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
The use of `ExitStatus` as the Rust type name for a Unix *wait
status*, not an *exit status*, is very confusing, but sadly probably
too late to change.

This area is confusing enough in Unix already (and many programmers
are already confuxed).  We can at least document it.

I chose *not* to mention the way shells like to exit with signal
numbers, thus turning signal numbers into exit statuses.  This is only
relevant for Rust programs using `std::process` if they run shells.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
@ijackson
Copy link
Contributor Author

LGTM once the tidy failure is resolved. Thanks!

Oops. My privsep workflow means I sometimes forget the tidy check. Fixed now (and squashed the fix in). Thanks.

@ijackson
Copy link
Contributor Author

ijackson commented Mar 3, 2021

@dtolnay Hi. Sorry to hassle you personally, but is there anything else I need to do here? I have a branch for #73125 which is blocked on this.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks for the reminder. I just had way too many things stack up, sorry for letting this drop. Looks good!

@dtolnay
Copy link
Member

dtolnay commented Mar 3, 2021

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 3, 2021

📌 Commit 4bb8425 has been approved by dtolnay

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 3, 2021
@ijackson
Copy link
Contributor Author

ijackson commented Mar 3, 2021

Thanks for the reminder. I just had way too many things stack up, sorry for letting this drop. Looks good!

No problem, I know the feeling. Thank you :-).

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Mar 4, 2021
Fixes to ExitStatus and its docs

* On Unix, properly display every possible wait status (and don't panic on weird values)
* In the documentation, be clear and consistent about "exit status" vs "wait status".
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Mar 4, 2021
Fixes to ExitStatus and its docs

* On Unix, properly display every possible wait status (and don't panic on weird values)
* In the documentation, be clear and consistent about "exit status" vs "wait status".
@JohnTitor
Copy link
Member

Failed in rollup: #82749 (comment)
@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 4, 2021
@ijackson
Copy link
Contributor Author

ijackson commented Mar 4, 2021

Failed in rollup: #82749 (comment)

Sorry about that. I will restrict the failing test cases to Linux.

ijackson added 2 commits March 4, 2021 12:18
MacOS uses a different representation.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
If different unices have different bit patterns for WIFSTOPPED and
WIFCONTINUED then simply being glibc is probably not good enough for
this rather ad-hoc test to work.  Do it on Linux only.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
@rust-log-analyzer

This comment has been minimized.

I strongly disagree with tidy in this case but AIUI there is no way to
override it.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
@ijackson
Copy link
Contributor Author

ijackson commented Mar 4, 2021

OK I think I have fixed this now.

@rustbot modify labels -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 4, 2021
@ijackson
Copy link
Contributor Author

ijackson commented Mar 4, 2021

@JohnTitor Should I be asking you to re-approve it, or ...? (Thanks for your attention and sorry for messing up your rollup.)

@ijackson
Copy link
Contributor Author

ijackson commented Mar 4, 2021

@JohnTitor (or anyone) Also, if I may ask: if I have a branch which I suspect might have portability problems, is there a less disruptive way for me to get the full rust CI run on it than to try to get it approved, and wait for it to make a mess for you?

I could ask the reviewer to mark it not for rollup, but ideally I would get the computers to find the problems before bothering a human reviewer with re-review over portability fixes.

@JohnTitor
Copy link
Member

Seems reasonable to me but I'm not part of the reviewers so r? @dtolnay
Btw, don't worry about the rollup failure, it's not so hard to re-create a new one :)

Also, if I may ask: if I have a branch which I suspect might have portability problems, is there a less disruptive way for me to get the full rust CI run on it than to try to get it approved, and wait for it to make a mess for you?

If it makes sense, we can run a try build (via bors try) to check the change on some more builders than PR's.

…itionally

Co-authored-by: David Tolnay <dtolnay@gmail.com>
@ijackson ijackson requested a review from dtolnay March 9, 2021 13:32
@dtolnay
Copy link
Member

dtolnay commented Mar 9, 2021

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 9, 2021

📌 Commit 11ca644 has been approved by dtolnay

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 9, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Mar 9, 2021
Fixes to ExitStatus and its docs

* On Unix, properly display every possible wait status (and don't panic on weird values)
* In the documentation, be clear and consistent about "exit status" vs "wait status".
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Mar 9, 2021
Fixes to ExitStatus and its docs

* On Unix, properly display every possible wait status (and don't panic on weird values)
* In the documentation, be clear and consistent about "exit status" vs "wait status".
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 10, 2021
Rollup of 10 pull requests

Successful merges:

 - rust-lang#77511 (Add StatementKind::CopyNonOverlapping)
 - rust-lang#79208 (Stabilize `unsafe_op_in_unsafe_fn` lint)
 - rust-lang#82411 (Fixes to ExitStatus and its docs)
 - rust-lang#82733 (Add powerpc-unknown-openbsd target)
 - rust-lang#82802 (Build rustdoc for run-make tests, not just run-make-fulldeps)
 - rust-lang#82849 (Add Option::get_or_default)
 - rust-lang#82908 (:arrow_up: rust-analyzer)
 - rust-lang#82937 (Update README.md to use the correct cmake version number)
 - rust-lang#82938 (Bump tracing-tree dependency)
 - rust-lang#82942 (Don't hardcode the `v1` prelude in diagnostics, to allow for new preludes.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 74e74e9 into rust-lang:master Mar 10, 2021
@rustbot rustbot added this to the 1.52.0 milestone Mar 10, 2021
@ijackson ijackson deleted the fix-exitstatus branch March 10, 2021 11:04
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants