Skip to content

Commit 91e47be

Browse files
ijacksonm-ou-se
andcommitted
unix process: pre_exec: Discuss panic safety
Signed-off-by: Ian Jackson <[email protected]> Co-authored-by: Mara Bos <[email protected]>
1 parent 597db87 commit 91e47be

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

std/src/os/unix/process.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ pub trait CommandExt: Sealed {
7575
/// sure that the closure does not violate library invariants by making
7676
/// invalid use of these duplicates.
7777
///
78+
/// Panicking in the closure is safe only if all the format arguments for the
79+
/// panic message can be safely formatted; this is because although
80+
/// `Command` calls [`std::panic::always_abort`](crate::panic::always_abort)
81+
/// before calling the pre_exec hook, panic will still try to format the
82+
/// panic message.
83+
///
7884
/// When this closure is run, aspects such as the stdio file descriptors and
7985
/// working directory have successfully been changed, so output to these
8086
/// locations may not appear where intended.

0 commit comments

Comments
 (0)