File tree 1 file changed +4
-3
lines changed
library/std/src/sys/unix/process
1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -66,14 +66,15 @@ impl Command {
66
66
//
67
67
// Note that as soon as we're done with the fork there's no need to hold
68
68
// a lock any more because the parent won't do anything and the child is
69
- // in its own process. Thus the parent drops the lock guard while the child
70
- // forgets it to avoid unlocking it on a new thread, which would be invalid.
69
+ // in its own process. Thus the parent drops the lock guard immediately.
70
+ // The child calls `mem::forget` to leak the lock, which is crucial because
71
+ // releasing a lock is not async-signal-safe.
71
72
let env_lock = sys:: os:: env_read_lock ( ) ;
72
73
let ( pid, pidfd) = unsafe { self . do_fork ( ) ? } ;
73
74
74
75
if pid == 0 {
75
76
crate :: panic:: always_abort ( ) ;
76
- mem:: forget ( env_lock) ;
77
+ mem:: forget ( env_lock) ; // avoid non-async-signal-safe unlocking
77
78
drop ( input) ;
78
79
let Err ( err) = unsafe { self . do_exec ( theirs, envp. as_ref ( ) ) } ;
79
80
let errno = err. raw_os_error ( ) . unwrap_or ( libc:: EINVAL ) as u32 ;
You can’t perform that action at this time.
0 commit comments