Module Name: src Committed By: christos Date: Mon Apr 4 20:47:57 UTC 2016
Modified Files: src/sys/kern: kern_event.c kern_exec.c kern_exit.c kern_lwp.c kern_proc.c kern_sig.c kern_synch.c sys_process.c src/sys/miscfs/procfs: procfs_ctl.c src/sys/rump/librump/rumpkern: lwproc.c src/sys/sys: proc.h Log Message: Split p_xstat (composite wait(2) status code, or signal number depending on context) into: 1. p_xexit: exit code 2. p_xsig: signal number 3. p_sflag & WCOREFLAG bit to indicated that the process core-dumped. Fix the documentation of the flag bits in <sys/proc.h> To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/sys/kern/kern_event.c cvs rdiff -u -r1.424 -r1.425 src/sys/kern/kern_exec.c cvs rdiff -u -r1.251 -r1.252 src/sys/kern/kern_exit.c cvs rdiff -u -r1.182 -r1.183 src/sys/kern/kern_lwp.c cvs rdiff -u -r1.194 -r1.195 src/sys/kern/kern_proc.c cvs rdiff -u -r1.321 -r1.322 src/sys/kern/kern_sig.c cvs rdiff -u -r1.309 -r1.310 src/sys/kern/kern_synch.c cvs rdiff -u -r1.167 -r1.168 src/sys/kern/sys_process.c cvs rdiff -u -r1.47 -r1.48 src/sys/miscfs/procfs/procfs_ctl.c cvs rdiff -u -r1.38 -r1.39 src/sys/rump/librump/rumpkern/lwproc.c cvs rdiff -u -r1.327 -r1.328 src/sys/sys/proc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_event.c diff -u src/sys/kern/kern_event.c:1.85 src/sys/kern/kern_event.c:1.86 --- src/sys/kern/kern_event.c:1.85 Sat Jan 30 23:40:01 2016 +++ src/sys/kern/kern_event.c Mon Apr 4 16:47:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_event.c,v 1.85 2016/01/31 04:40:01 christos Exp $ */ +/* $NetBSD: kern_event.c,v 1.86 2016/04/04 20:47:57 christos Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -58,11 +58,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.85 2016/01/31 04:40:01 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.86 2016/04/04 20:47:57 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> +#include <sys/wait.h> #include <sys/proc.h> #include <sys/file.h> #include <sys/select.h> @@ -551,7 +552,7 @@ filt_proc(struct knote *kn, long hint) struct proc *p = kn->kn_obj; if (p != NULL) - kn->kn_data = p->p_xstat; + kn->kn_data = P_WAITSTATUS(p); /* * Process is gone, so flag the event as finished. * Index: src/sys/kern/kern_exec.c diff -u src/sys/kern/kern_exec.c:1.424 src/sys/kern/kern_exec.c:1.425 --- src/sys/kern/kern_exec.c:1.424 Sun Mar 20 10:58:10 2016 +++ src/sys/kern/kern_exec.c Mon Apr 4 16:47:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.424 2016/03/20 14:58:10 khorben Exp $ */ +/* $NetBSD: kern_exec.c,v 1.425 2016/04/04 20:47:57 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.424 2016/03/20 14:58:10 khorben Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.425 2016/04/04 20:47:57 christos Exp $"); #include "opt_exec.h" #include "opt_execfmt.h" @@ -1350,7 +1350,7 @@ execve_runproc(struct lwp *l, struct exe /* Acquire the sched-state mutex (exit1() will release it). */ if (!is_spawn) { mutex_enter(p->p_lock); - exit1(l, W_EXITCODE(error, SIGABRT)); + exit1(l, error, SIGABRT, 0); } return error; @@ -2229,7 +2229,7 @@ spawn_return(void *arg) * A NetBSD specific workaround is POSIX_SPAWN_RETURNERROR as * flag bit in the attrp argument to posix_spawn(2), see above. */ - exit1(l, W_EXITCODE(127, 0)); + exit1(l, 127, 0, 0); } void Index: src/sys/kern/kern_exit.c diff -u src/sys/kern/kern_exit.c:1.251 src/sys/kern/kern_exit.c:1.252 --- src/sys/kern/kern_exit.c:1.251 Sun Apr 3 19:50:49 2016 +++ src/sys/kern/kern_exit.c Mon Apr 4 16:47:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exit.c,v 1.251 2016/04/03 23:50:49 christos Exp $ */ +/* $NetBSD: kern_exit.c,v 1.252 2016/04/04 20:47:57 christos Exp $ */ /*- * Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.251 2016/04/03 23:50:49 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.252 2016/04/04 20:47:57 christos Exp $"); #include "opt_ktrace.h" #include "opt_dtrace.h" @@ -138,14 +138,19 @@ exit_psignal(struct proc *p, struct proc KSI_INIT(ksi); if ((ksi->ksi_signo = P_EXITSIG(p)) == SIGCHLD) { - if (WIFSIGNALED(p->p_xstat)) { - if (WCOREDUMP(p->p_xstat)) + if (p->p_xsig) { + if (p->p_sflag & PS_COREDUMP) ksi->ksi_code = CLD_DUMPED; else ksi->ksi_code = CLD_KILLED; + ksi->ksi_status = p->p_xsig; } else { ksi->ksi_code = CLD_EXITED; + ksi->ksi_status = p->p_xexit; } + } else { + ksi->ksi_code = SI_USER; + ksi->ksi_status = p->p_xsig; } /* * We fill those in, even for non-SIGCHLD. @@ -153,7 +158,6 @@ exit_psignal(struct proc *p, struct proc */ ksi->ksi_pid = p->p_pid; ksi->ksi_uid = kauth_cred_geteuid(p->p_cred); - ksi->ksi_status = p->p_xstat; /* XXX: is this still valid? */ ksi->ksi_utime = p->p_stats->p_ru.ru_utime.tv_sec; ksi->ksi_stime = p->p_stats->p_ru.ru_stime.tv_sec; @@ -179,7 +183,7 @@ sys_exit(struct lwp *l, const struct sys } /* exit1() will release the mutex. */ - exit1(l, W_EXITCODE(SCARG(uap, rval), 0)); + exit1(l, SCARG(uap, rval), 0, 0); /* NOTREACHED */ return (0); } @@ -192,7 +196,7 @@ sys_exit(struct lwp *l, const struct sys * Must be called with p->p_lock held. Does not return. */ void -exit1(struct lwp *l, int rv) +exit1(struct lwp *l, int exitcode, int signo, int coredump) { struct proc *p, *child, *next_child, *old_parent, *new_parent; struct pgrp *pgrp; @@ -206,8 +210,7 @@ exit1(struct lwp *l, int rv) KASSERT(p->p_vmspace != NULL); if (__predict_false(p == initproc)) { - panic("init died (signal %d, exit %d)", - WTERMSIG(rv), WEXITSTATUS(rv)); + panic("init died (signal %d, exit %d)", signo, exitcode); } p->p_sflag |= PS_WEXIT; @@ -269,7 +272,7 @@ exit1(struct lwp *l, int rv) */ rw_enter(&p->p_reflock, RW_WRITER); - DPRINTF(("exit1: %d.%d exiting.\n", p->p_pid, l->l_lid)); + DPRINTF(("%s: %d.%d exiting.\n", __func__, p->p_pid, l->l_lid)); timers_free(p, TIMERS_ALL); #if defined(__HAVE_RAS) @@ -302,13 +305,17 @@ exit1(struct lwp *l, int rv) } #endif + p->p_xexit = exitcode; + p->p_xsig = signo; + if (coredump) + p->p_sflag |= PS_COREDUMP; + /* * If emulation has process exit hook, call it now. * Set the exit status now so that the exit hook has * an opportunity to tweak it (COMPAT_LINUX requires * this for thread group emulation) */ - p->p_xstat = rv; if (p->p_emul->e_proc_exit) (*p->p_emul->e_proc_exit)(p); @@ -423,8 +430,8 @@ exit1(struct lwp *l, int rv) KNOTE(&p->p_klist, NOTE_EXIT); SDT_PROBE(proc, kernel, , exit, - (WCOREDUMP(rv) ? CLD_DUMPED : - (WIFSIGNALED(rv) ? CLD_KILLED : CLD_EXITED)), + ((p->p_sflag & PS_COREDUMP) ? CLD_DUMPED : + (p->p_xsig ? CLD_KILLED : CLD_EXITED)), 0,0,0,0); #if PERFCTRS @@ -869,15 +876,15 @@ match_process(struct proc *pp, struct pr * This is still a rough estimate. We will fix the * cases TRAPPED, STOPPED, and CONTINUED later. */ - if (WCOREDUMP(p->p_xstat)) { + if (p->p_sflag & PS_COREDUMP) { siginfo->si_code = CLD_DUMPED; - siginfo->si_status = WTERMSIG(p->p_xstat); - } else if (WIFSIGNALED(p->p_xstat)) { + siginfo->si_status = p->p_xsig; + } else if (p->p_xsig) { siginfo->si_code = CLD_KILLED; - siginfo->si_status = WTERMSIG(p->p_xstat); + siginfo->si_status = p->p_xsig; } else { siginfo->si_code = CLD_EXITED; - siginfo->si_status = WEXITSTATUS(p->p_xstat); + siginfo->si_status = p->p_xexit; } siginfo->si_pid = p->p_pid; @@ -991,13 +998,13 @@ find_stopped_child(struct proc *parent, } if ((options & WCONTINUED) != 0 && - child->p_xstat == SIGCONT) { + child->p_xsig == SIGCONT) { if ((options & WNOWAIT) == 0) { child->p_waited = 1; parent->p_nstopchild--; } if (si) { - si->si_status = child->p_xstat; + si->si_status = child->p_xsig; si->si_code = CLD_CONTINUED; } break; @@ -1013,7 +1020,7 @@ find_stopped_child(struct proc *parent, parent->p_nstopchild--; } if (si) { - si->si_status = child->p_xstat; + si->si_status = child->p_xsig; si->si_code = (child->p_slflag & PSL_TRACED) ? CLD_TRAPPED : CLD_STOPPED; @@ -1030,7 +1037,7 @@ find_stopped_child(struct proc *parent, if (child != NULL || error != 0 || ((options & WNOHANG) != 0 && dead == NULL)) { if (child != NULL) { - *status_p = child->p_xstat; + *status_p = child->p_xsig; } *child_p = child; return error; @@ -1109,7 +1116,8 @@ proc_free(struct proc *p, struct wrusage wru->wru_self = p->p_stats->p_ru; wru->wru_children = p->p_stats->p_cru; } - p->p_xstat = 0; + p->p_xsig = 0; + p->p_xexit = 0; /* * At this point we are going to start freeing the final resources. Index: src/sys/kern/kern_lwp.c diff -u src/sys/kern/kern_lwp.c:1.182 src/sys/kern/kern_lwp.c:1.183 --- src/sys/kern/kern_lwp.c:1.182 Thu Nov 26 08:15:34 2015 +++ src/sys/kern/kern_lwp.c Mon Apr 4 16:47:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_lwp.c,v 1.182 2015/11/26 13:15:34 martin Exp $ */ +/* $NetBSD: kern_lwp.c,v 1.183 2016/04/04 20:47:57 christos Exp $ */ /*- * Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -211,7 +211,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.182 2015/11/26 13:15:34 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.183 2016/04/04 20:47:57 christos Exp $"); #include "opt_ddb.h" #include "opt_lockdebug.h" @@ -509,7 +509,7 @@ lwp_unstop(struct lwp *l) if (l->l_wchan == NULL) { /* setrunnable() will release the lock. */ setrunnable(l); - } else if (p->p_xstat && (l->l_flag & LW_SINTR) != 0) { + } else if (p->p_xsig && (l->l_flag & LW_SINTR) != 0) { /* setrunnable() so we can receive the signal */ setrunnable(l); } else { @@ -1043,7 +1043,7 @@ lwp_exit(struct lwp *l) KASSERT(current == true); KASSERT(p != &proc0); /* XXXSMP kernel_lock not held */ - exit1(l, 0); + exit1(l, 0, 0, 0); /* NOTREACHED */ } p->p_nzlwps++; Index: src/sys/kern/kern_proc.c diff -u src/sys/kern/kern_proc.c:1.194 src/sys/kern/kern_proc.c:1.195 --- src/sys/kern/kern_proc.c:1.194 Thu Sep 24 10:33:01 2015 +++ src/sys/kern/kern_proc.c Mon Apr 4 16:47:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_proc.c,v 1.194 2015/09/24 14:33:01 christos Exp $ */ +/* $NetBSD: kern_proc.c,v 1.195 2016/04/04 20:47:57 christos Exp $ */ /*- * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.194 2015/09/24 14:33:01 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.195 2016/04/04 20:47:57 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_kstack.h" @@ -2283,7 +2283,7 @@ fill_kproc2(struct proc *p, struct kinfo ki->p_stat = p->p_stat; /* Will likely be overridden by LWP status */ ki->p_realstat = p->p_stat; ki->p_nice = p->p_nice; - ki->p_xstat = p->p_xstat; + ki->p_xstat = P_WAITSTATUS(p); ki->p_acflag = p->p_acflag; strncpy(ki->p_comm, p->p_comm, Index: src/sys/kern/kern_sig.c diff -u src/sys/kern/kern_sig.c:1.321 src/sys/kern/kern_sig.c:1.322 --- src/sys/kern/kern_sig.c:1.321 Tue Oct 13 03:00:59 2015 +++ src/sys/kern/kern_sig.c Mon Apr 4 16:47:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sig.c,v 1.321 2015/10/13 07:00:59 pgoyette Exp $ */ +/* $NetBSD: kern_sig.c,v 1.322 2016/04/04 20:47:57 christos Exp $ */ /*- * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.321 2015/10/13 07:00:59 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.322 2016/04/04 20:47:57 christos Exp $"); #include "opt_ptrace.h" #include "opt_dtrace.h" @@ -916,19 +916,19 @@ child_psignal(struct proc *p, int mask) { ksiginfo_t ksi; struct proc *q; - int xstat; + int xsig; KASSERT(mutex_owned(proc_lock)); KASSERT(mutex_owned(p->p_lock)); - xstat = p->p_xstat; + xsig = p->p_xsig; KSI_INIT(&ksi); ksi.ksi_signo = SIGCHLD; - ksi.ksi_code = (xstat == SIGCONT ? CLD_CONTINUED : CLD_STOPPED); + ksi.ksi_code = (xsig == SIGCONT ? CLD_CONTINUED : CLD_STOPPED); ksi.ksi_pid = p->p_pid; ksi.ksi_uid = kauth_cred_geteuid(p->p_cred); - ksi.ksi_status = xstat; + ksi.ksi_status = xsig; ksi.ksi_utime = p->p_stats->p_ru.ru_utime.tv_sec; ksi.ksi_stime = p->p_stats->p_ru.ru_stime.tv_sec; @@ -1566,7 +1566,7 @@ sigchecktrace(void) * If we are no longer being traced, or the parent didn't * give us a signal, or we're stopping, look for more signals. */ - if ((p->p_slflag & PSL_TRACED) == 0 || p->p_xstat == 0 || + if ((p->p_slflag & PSL_TRACED) == 0 || p->p_xsig == 0 || (p->p_sflag & PS_STOPPING) != 0) return 0; @@ -1574,8 +1574,8 @@ sigchecktrace(void) * If the new signal is being masked, look for other signals. * `p->p_sigctx.ps_siglist |= mask' is done in setrunnable(). */ - signo = p->p_xstat; - p->p_xstat = 0; + signo = p->p_xsig; + p->p_xsig = 0; if (sigismember(&l->l_sigmask, signo)) { signo = 0; } @@ -1685,7 +1685,7 @@ issignal(struct lwp *l) */ if (sp) sigdelset(&sp->sp_set, signo); - p->p_xstat = signo; + p->p_xsig = signo; /* Emulation-specific handling of signal trace */ if (p->p_emul->e_tracesig == NULL || @@ -1742,9 +1742,9 @@ issignal(struct lwp *l) } /* Take the signal. */ (void)sigget(sp, NULL, signo, NULL); - p->p_xstat = signo; + p->p_xsig = signo; signo = 0; - sigswitch(true, PS_NOCLDSTOP, p->p_xstat); + sigswitch(true, PS_NOCLDSTOP, p->p_xsig); } else if (prop & SA_IGNORE) { /* * Except for SIGCONT, shouldn't get here. @@ -1946,7 +1946,7 @@ killproc(struct proc *p, const char *why void sigexit(struct lwp *l, int signo) { - int exitsig, error, docore; + int exitsig, error, docore, coreflag = 0; struct proc *p; struct lwp *t; @@ -2018,7 +2018,7 @@ sigexit(struct lwp *l, int signo) if (docore) { mutex_exit(p->p_lock); if ((error = (*coredump_vec)(l, NULL)) == 0) - exitsig |= WCOREFLAG; + coreflag = 1; if (kern_logsigexit) { int uid = l->l_cred ? @@ -2042,7 +2042,7 @@ sigexit(struct lwp *l, int signo) /* No longer dumping core. */ p->p_sflag &= ~PS_WCORE; - exit1(l, W_EXITCODE(0, exitsig)); + exit1(l, 0, exitsig, coreflag); /* NOTREACHED */ } @@ -2183,7 +2183,7 @@ proc_unstop(struct proc *p) p->p_stat = SACTIVE; p->p_sflag &= ~PS_STOPPING; - sig = p->p_xstat; + sig = p->p_xsig; if (!p->p_waited) p->p_pptr->p_nstopchild--; Index: src/sys/kern/kern_synch.c diff -u src/sys/kern/kern_synch.c:1.309 src/sys/kern/kern_synch.c:1.310 --- src/sys/kern/kern_synch.c:1.309 Mon Oct 12 20:25:51 2015 +++ src/sys/kern/kern_synch.c Mon Apr 4 16:47:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_synch.c,v 1.309 2015/10/13 00:25:51 pgoyette Exp $ */ +/* $NetBSD: kern_synch.c,v 1.310 2016/04/04 20:47:57 christos Exp $ */ /*- * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009 @@ -69,7 +69,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.309 2015/10/13 00:25:51 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.310 2016/04/04 20:47:57 christos Exp $"); #include "opt_kstack.h" #include "opt_perfctrs.h" @@ -907,7 +907,7 @@ setrunnable(struct lwp *l) * If we're being traced (possibly because someone attached us * while we were stopped), check for a signal from the debugger. */ - if ((p->p_slflag & PSL_TRACED) != 0 && p->p_xstat != 0) + if ((p->p_slflag & PSL_TRACED) != 0 && p->p_xsig != 0) signotify(l); p->p_nrlwps++; break; Index: src/sys/kern/sys_process.c diff -u src/sys/kern/sys_process.c:1.167 src/sys/kern/sys_process.c:1.168 --- src/sys/kern/sys_process.c:1.167 Sat Jan 9 02:52:38 2016 +++ src/sys/kern/sys_process.c Mon Apr 4 16:47:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_process.c,v 1.167 2016/01/09 07:52:38 dholland Exp $ */ +/* $NetBSD: sys_process.c,v 1.168 2016/04/04 20:47:57 christos Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -118,7 +118,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.167 2016/01/09 07:52:38 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.168 2016/04/04 20:47:57 christos Exp $"); #include "opt_ptrace.h" #include "opt_ktrace.h" @@ -740,7 +740,7 @@ sys_ptrace(struct lwp *l, const struct s * signal, make all efforts to ensure that at * an LWP runs to see it. */ - t->p_xstat = signo; + t->p_xsig = signo; if (resume_all) proc_unstop(t); else @@ -1146,7 +1146,7 @@ process_stoptrace(void) return; } - p->p_xstat = SIGTRAP; + p->p_xsig = SIGTRAP; proc_stop(p, 1, SIGSTOP); mutex_exit(proc_lock); Index: src/sys/miscfs/procfs/procfs_ctl.c diff -u src/sys/miscfs/procfs/procfs_ctl.c:1.47 src/sys/miscfs/procfs/procfs_ctl.c:1.48 --- src/sys/miscfs/procfs/procfs_ctl.c:1.47 Wed Oct 21 17:12:06 2009 +++ src/sys/miscfs/procfs/procfs_ctl.c Mon Apr 4 16:47:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: procfs_ctl.c,v 1.47 2009/10/21 21:12:06 rmind Exp $ */ +/* $NetBSD: procfs_ctl.c,v 1.48 2016/04/04 20:47:57 christos Exp $ */ /* * Copyright (c) 1993 @@ -72,7 +72,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: procfs_ctl.c,v 1.47 2009/10/21 21:12:06 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: procfs_ctl.c,v 1.48 2016/04/04 20:47:57 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -317,7 +317,7 @@ procfs_control(struct lwp *curl, struct /* Finally, deliver the requested signal (or none). */ lwp_lock(l); if (l->l_stat == LSSTOP) { - p->p_xstat = sig; + p->p_xsig = sig; /* setrunnable() will release the lock. */ setrunnable(l); } else { Index: src/sys/rump/librump/rumpkern/lwproc.c diff -u src/sys/rump/librump/rumpkern/lwproc.c:1.38 src/sys/rump/librump/rumpkern/lwproc.c:1.39 --- src/sys/rump/librump/rumpkern/lwproc.c:1.38 Mon Feb 8 13:18:19 2016 +++ src/sys/rump/librump/rumpkern/lwproc.c Mon Apr 4 16:47:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: lwproc.c,v 1.38 2016/02/08 18:18:19 pooka Exp $ */ +/* $NetBSD: lwproc.c,v 1.39 2016/04/04 20:47:57 christos Exp $ */ /* * Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ #define RUMP__CURLWP_PRIVATE #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.38 2016/02/08 18:18:19 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.39 2016/04/04 20:47:57 christos Exp $"); #include <sys/param.h> #include <sys/atomic.h> @@ -211,7 +211,7 @@ lwproc_newproc(struct proc *parent, stru p->p_mqueue_cnt = p->p_exitsig = 0; p->p_flag = p->p_sflag = p->p_slflag = p->p_lflag = p->p_stflag = 0; p->p_trace_enabled = 0; - p->p_xstat = p->p_acflag = 0; + p->p_xsig = p->p_xexit = p->p_acflag = 0; p->p_stackbase = 0; p->p_stats = pstatscopy(parent->p_stats); Index: src/sys/sys/proc.h diff -u src/sys/sys/proc.h:1.327 src/sys/sys/proc.h:1.328 --- src/sys/sys/proc.h:1.327 Mon Nov 30 20:19:02 2015 +++ src/sys/sys/proc.h Mon Apr 4 16:47:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.327 2015/12/01 01:19:02 pgoyette Exp $ */ +/* $NetBSD: proc.h,v 1.328 2016/04/04 20:47:57 christos Exp $ */ /*- * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -326,12 +326,12 @@ struct proc { vaddr_t p_psstrp; /* :: address of process's ps_strings */ u_int p_pax; /* :: PAX flags */ + int p_xexit; /* p: exit code */ /* * End area that is copied on creation */ -#define p_endcopy p_xstat - - u_short p_xstat; /* p: Exit status for wait; also stop signal */ +#define p_endcopy p_xsig + u_short p_xsig; /* p: stop signal */ u_short p_acflag; /* p: Acc. flags; see struct lwp also */ struct mdproc p_md; /* p: Any machine-dependent fields */ vaddr_t p_stackbase; /* :: ASLR randomized stack base */ @@ -383,10 +383,11 @@ struct proc { #define PS_STOPEXEC 0x01000000 /* Will be stopped on exec(2) */ #define PS_STOPEXIT 0x02000000 /* Will be stopped at process exit */ #define PS_NOTIFYSTOP 0x10000000 /* Notify parent of successful STOP */ +#define PS_COREDUMP 0x20000000 /* Process core-dumped */ #define PS_STOPPING 0x80000000 /* Transitioning SACTIVE -> SSTOP */ /* - * These flags are kept in p_sflag and are protected by the proc_lock + * These flags are kept in p_slflag and are protected by the proc_lock * and p_lock. Access from process context only. */ #define PSL_TRACEFORK 0x00000001 /* traced process wants fork events */ @@ -402,7 +403,7 @@ struct proc { #define PST_PROFIL 0x00000020 /* Has started profiling */ /* - * The final set are protected by the proc_lock. Access + * Kept in p_lflag and protected by the proc_lock. Access * from process context only. */ #define PL_CONTROLT 0x00000002 /* Has a controlling terminal */ @@ -417,6 +418,11 @@ struct proc { */ #define P_EXITSIG(p) \ (((p)->p_slflag & (PSL_TRACED|PSL_FSTRACE)) ? SIGCHLD : p->p_exitsig) +/* + * Compute a wait(2) 16 bit exit status code + */ +#define P_WAITSTATUS(p) W_EXITCODE((p)->p_xexit, ((p)->p_xsig | \ + (((p)->p_sflag & PS_COREDUMP) ? WCOREFLAG : 0))) LIST_HEAD(proclist, proc); /* A list of processes */ @@ -485,7 +491,7 @@ int tsleep(wchan_t, pri_t, const char *, int mtsleep(wchan_t, pri_t, const char *, int, kmutex_t *); void wakeup(wchan_t); int kpause(const char *, bool, int, kmutex_t *); -void exit1(struct lwp *, int) __dead; +void exit1(struct lwp *, int, int, int) __dead; int kill1(struct lwp *l, pid_t pid, ksiginfo_t *ksi, register_t *retval); int do_sys_wait(int *, int *, int, struct rusage *); struct proc *proc_alloc(void);