Skip to content

Commit 3f41fdd

Browse files
authored
Rollup merge of #83462 - ijackson:exitstatus-message-wording, r=joshtriplett
ExitStatus: print "exit status: {}" rather than "exit code: {}" on unix Proper Unix terminology is "exit status" (vs "wait status"). "exit code" is imprecise on Unix and therefore unclear. (As far as I can tell, "exit code" is correct terminology on Windows.) This new wording is unfortunately inconsistent with the identifier names in the Rust stdlib. It is the identifier names that are wrong, as discussed at length in eg https://doc.rust-lang.org/nightly/std/process/struct.ExitStatus.html https://doc.rust-lang.org/nightly/std/os/unix/process/trait.ExitStatusExt.html Unfortunately for API stability reasons it would be a lot of work, and a lot of disruption, to change the names in the stdlib (eg to rename `std::process::ExitStatus` to `std::process::ChildStatus` or something), but we should fix the message output. Many (probably most) readers of these messages about exit statuses will be users and system administrators, not programmers, who won't even know that Rust has this wrong terminology. So I think the right thing is to fix the documentation (as I have already done) and, now, the terminology in the implementation. This is a user-visible change to the behaviour of all Rust programs which run Unix subprocesses. Hopefully no-one is matching against the exit status string, except perhaps in tests.
2 parents 973fb4b + 11e40ce commit 3f41fdd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

library/std/src/sys/unix/process/process_unix.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ impl From<c_int> for ExitStatus {
535535
impl fmt::Display for ExitStatus {
536536
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
537537
if let Some(code) = self.code() {
538-
write!(f, "exit code: {}", code)
538+
write!(f, "exit status: {}", code)
539539
} else if let Some(signal) = self.signal() {
540540
if self.core_dumped() {
541541
write!(f, "signal: {} (core dumped)", signal)

library/std/src/sys/unix/process/process_unix/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ fn exitstatus_display_tests() {
99

1010
t(0x0000f, "signal: 15");
1111
t(0x0008b, "signal: 11 (core dumped)");
12-
t(0x00000, "exit code: 0");
13-
t(0x0ff00, "exit code: 255");
12+
t(0x00000, "exit status: 0");
13+
t(0x0ff00, "exit status: 255");
1414

1515
// On MacOS, 0x0137f is WIFCONTINUED, not WIFSTOPPED. Probably *BSD is similar.
1616
// https://github.com/rust-lang/rust/pull/82749#issuecomment-790525956

0 commit comments

Comments
 (0)