about summary refs log tree commit diff
path: root/library/std/src/os
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2021-02-07 13:41:49 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2021-05-07 11:17:44 +0100
commit9283cdca362065a215e7f8b460719947493ddc54 (patch)
treece1cf019ab07cbf48db433a8a67a3ad4d6b8f765 /library/std/src/os
parent820123a949705f404ff080759c32dba4a4d89580 (diff)
downloadrust-9283cdca362065a215e7f8b460719947493ddc54.tar.gz
rust-9283cdca362065a215e7f8b460719947493ddc54.zip
unix process: pre_exec: Discuss panic safety
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
Diffstat (limited to 'library/std/src/os')
-rw-r--r--library/std/src/os/unix/process.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/library/std/src/os/unix/process.rs b/library/std/src/os/unix/process.rs
index 355855bcd10..f014a3d7b25 100644
--- a/library/std/src/os/unix/process.rs
+++ b/library/std/src/os/unix/process.rs
@@ -75,6 +75,12 @@ pub trait CommandExt: Sealed {
     /// sure that the closure does not violate library invariants by making
     /// invalid use of these duplicates.
     ///
+    /// Panicking in the closure is safe only if all the format arguments for the
+    /// panic message can be safely formatted; this is because although
+    /// `Command` calls [`std::panic::always_abort`](crate::panic::always_abort)
+    /// before calling the pre_exec hook, panic will still try to format the
+    /// panic message.
+    ///
     /// When this closure is run, aspects such as the stdio file descriptors and
     /// working directory have successfully been changed, so output to these
     /// locations may not appear where intended.