File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,8 +39,20 @@ pub fn try_wait_without_reaping(handle: Handle) -> io::Result<bool> {
3939 let mut siginfo: libc:: siginfo_t ;
4040 let ret = unsafe {
4141 // Darwin doesn't touch the siginfo_t struct if the child hasn't exited
42- // yet. It expects us to have zeroed it ahead of time. See:
43- // https://github.com/opensource-apple/xnu/blob/8cf668b09f7c419fadf6081d1f1bdd6c5033e708/bsd/kern/kern_exit.c#L2039-L2055
42+ // yet. It expects us to have zeroed it ahead of time:
43+ //
44+ // The state of the siginfo structure in this case
45+ // is undefined. Some implementations bzero it, some
46+ // (like here) leave it untouched for efficiency.
47+ //
48+ // Thus the most portable check for "no matching pid with
49+ // WNOHANG" is to store a zero into si_pid before
50+ // invocation, then check for a non-zero value afterwards.
51+ //
52+ // https://github.com/opensource-apple/xnu/blob/0a798f6738bc1db01281fc08ae024145e84df927/bsd/kern/kern_exit.c#L2150-L2156
53+ //
54+ // XXX: The siginfo_t struct has padding. Does that make it unsound to
55+ // initialize it this way?
4456 siginfo = std:: mem:: zeroed ( ) ;
4557 libc:: waitid (
4658 libc:: P_PID ,
You can’t perform that action at this time.
0 commit comments