From f948fdf9e9c8f3e33fa0b06ffba7d6fccc436694 Mon Sep 17 00:00:00 2001 From: jilles Date: Wed, 1 Jan 2014 20:22:29 +0000 Subject: MFC r258281: Fix siginfo_t.si_status for wait6/waitid/SIGCHLD. Per POSIX, si_status should contain the value passed to exit() for si_code==CLD_EXITED and the signal number for other si_code. This was incorrect for CLD_EXITED and CLD_DUMPED. This is still not fully POSIX-compliant (Austin group issue #594 says that the full value passed to exit() shall be returned via si_status, not just the low 8 bits) but is sufficient for a si_status-related test in libnih (upstart, Debian/kFreeBSD). PR: kern/184002 --- sys/kern/kern_exit.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sys/kern/kern_exit.c') diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index f0be10e..1a68bf5 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -974,16 +974,19 @@ proc_to_reap(struct thread *td, struct proc *p, idtype_t idtype, id_t id, * This is still a rough estimate. We will fix the * cases TRAPPED, STOPPED, and CONTINUED later. */ - if (WCOREDUMP(p->p_xstat)) + if (WCOREDUMP(p->p_xstat)) { siginfo->si_code = CLD_DUMPED; - else if (WIFSIGNALED(p->p_xstat)) + siginfo->si_status = WTERMSIG(p->p_xstat); + } else if (WIFSIGNALED(p->p_xstat)) { siginfo->si_code = CLD_KILLED; - else + siginfo->si_status = WTERMSIG(p->p_xstat); + } else { siginfo->si_code = CLD_EXITED; + siginfo->si_status = WEXITSTATUS(p->p_xstat); + } siginfo->si_pid = p->p_pid; siginfo->si_uid = p->p_ucred->cr_uid; - siginfo->si_status = p->p_xstat; /* * The si_addr field would be useful additional -- cgit v1.1