From 79e52b3f1ea5038de95372b45ffcb523d6b462a2 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 8 Nov 2021 17:28:02 +0000 Subject: [PATCH 1/3] unix::ExitStatusExt: Correct reference to _exit system call As discussed here https://github.com/rust-lang/rust/pull/88300#issuecomment-936085371 exit is (conventionally) a library function, with _exit being the actual system call. I have checked the other references and they say "if the process terminated by calling `exti`". I think despite the slight imprecision (strictly, it should read iff ... `_exit`), this is clearer. Anyone who knows about the distinction between `exit` and `_exit` will not be confused. `_exit` is the correct traditional name for the system call, despite Linux calling it `exit_group` or `exit`: https://www.freebsd.org/cgi/man.cgi?query=_exit&sektion=2&n=1 Signed-off-by: Ian Jackson --- library/std/src/os/unix/process.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/os/unix/process.rs b/library/std/src/os/unix/process.rs index 286a7c3b386f9..f573216157535 100644 --- a/library/std/src/os/unix/process.rs +++ b/library/std/src/os/unix/process.rs @@ -207,7 +207,7 @@ impl CommandExt for process::Command { /// [`ExitStatusError`](process::ExitStatusError). /// /// On Unix, `ExitStatus` **does not necessarily represent an exit status**, as -/// passed to the `exit` system call or returned by +/// passed to the `_exit` system call or returned by /// [`ExitStatus::code()`](crate::process::ExitStatus::code). It represents **any wait status** /// as returned by one of the `wait` family of system /// calls. From d1df4715ec851f7e8b019b4ed0fca14bac1dacc9 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 8 Nov 2021 17:38:01 +0000 Subject: [PATCH 2/3] unix::ExitStatus: Add comment saying that it's a wait status With cross-reference. Signed-off-by: Ian Jackson --- library/std/src/sys/unix/process/process_unix.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 99013efb495d0..7e674910f8e61 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -616,6 +616,9 @@ impl Process { } /// Unix exit statuses +// +// This is not actually an "exit status" in Unix terminology. Rather, it is a "wait status". +// See the discussion in comments and doc comments for `std::process::ExitStatus`. #[derive(PartialEq, Eq, Clone, Copy)] pub struct ExitStatus(c_int); From fe39fb314973f16dcb73b1f6ed8395aaf29299ec Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 8 Nov 2021 17:38:53 +0000 Subject: [PATCH 3/3] process::ExitStatus: Discuss `exit` vs `_exit` in a comment. As discussed here https://github.com/rust-lang/rust/pull/88300#issuecomment-936097710 I felt this was the best place to put this (rather than next to ExitStatusExt). After all, it's a property of the ExitStatus type on Unix. Signed-off-by: Ian Jackson --- library/std/src/process.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 9cc7fc2f0352e..b4dab41f06632 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -1417,6 +1417,11 @@ impl From for Stdio { /// /// [`status`]: Command::status /// [`wait`]: Child::wait +// +// We speak slightly loosely (here and in various other places in the stdlib docs) about `exit` +// vs `_exit`. Naming of Unix system calls is not standardised across Unices, so terminology is a +// matter of convention and tradition. For clarity we usually speak of `exit`, even when we might +// mean an underlying system call such as `_exit`. #[derive(PartialEq, Eq, Clone, Copy, Debug)] #[stable(feature = "process", since = "1.0.0")] pub struct ExitStatus(imp::ExitStatus);