Skip to content

Commit 0971cb1

Browse files
committed
Document platform-specific differences for std::process::exit.
Fixes #35046.
1 parent d250169 commit 0971cb1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/libstd/process.rs

+17
Original file line numberDiff line numberDiff line change
@@ -828,13 +828,30 @@ impl Child {
828828
/// this function at a known point where there are no more destructors left
829829
/// to run.
830830
///
831+
/// ## Platform-specific behavior
832+
///
833+
/// **Unix**: On Unix-like platforms, it is unlikely that all 32 bits of `exit`
834+
/// will be visible to a parent process inspecting the exit code. On most
835+
/// Unix-like platforms, only the eight least-significant bits are considered.
836+
///
831837
/// # Examples
832838
///
833839
/// ```
834840
/// use std::process;
835841
///
836842
/// process::exit(0);
837843
/// ```
844+
///
845+
/// Due to [platform-specific behavior], the exit code for this example will be
846+
/// `0` on Linux, but `256` on Windows:
847+
///
848+
/// ```
849+
/// use std::process;
850+
///
851+
/// process::exit(0x0f00);
852+
/// ```
853+
///
854+
/// [platform-specific behavior]: #platform-specific-behavior
838855
#[stable(feature = "rust1", since = "1.0.0")]
839856
pub fn exit(code: i32) -> ! {
840857
::sys_common::cleanup();

0 commit comments

Comments
 (0)