Skip to content

Commit d942f1a

Browse files
committed
update the link to Darwin source code
1 parent 8ca2d65 commit d942f1a

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/sys/unix.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)