diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 19266a36b8bf..9bf02cde9ddc 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exit.c,v 1.129 2003/11/17 22:52:09 cl Exp $ */ +/* $NetBSD: kern_exit.c,v 1.130 2003/12/06 04:16:33 atatat Exp $ */ /*- * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. @@ -74,7 +74,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.129 2003/11/17 22:52:09 cl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.130 2003/12/06 04:16:33 atatat Exp $"); #include "opt_ktrace.h" #include "opt_perfctrs.h" @@ -199,6 +199,18 @@ exit1(struct lwp *l, int rv) WTERMSIG(rv), WEXITSTATUS(rv)); p->p_flag |= P_WEXIT; + if (p->p_flag & P_STOPEXIT) { + int s; + + sigminusset(&contsigmask, &p->p_sigctx.ps_siglist); + SCHED_LOCK(s); + p->p_stat = SSTOP; + l->l_stat = LSSTOP; + p->p_nrlwps--; + mi_switch(l, NULL); + SCHED_ASSERT_UNLOCKED(); + splx(s); + } DPRINTF(("exit1: %d.%d exiting.\n", p->p_pid, l->l_lid)); /* diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 35318dd228a4..42438fd027d4 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.181 2003/12/05 21:12:44 jdolecek Exp $ */ +/* $NetBSD: proc.h,v 1.182 2003/12/06 04:16:33 atatat Exp $ */ /*- * Copyright (c) 1986, 1989, 1991, 1993 @@ -301,6 +301,7 @@ struct proc { #define P_CHTRACED 0x00400000 /* Child has been traced & reparented */ #define P_STOPFORK 0x00800000 /* Child will be stopped on fork(2) */ #define P_STOPEXEC 0x01000000 /* Will be stopped on exec(2) */ +#define P_STOPEXIT 0x02000000 /* Will be stopped at process exit */ /* * Macro to compute the exit signal to be delivered. diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 4b5900acc017..9db044c012d0 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $NetBSD: sysctl.h,v 1.101 2003/12/04 20:06:58 atatat Exp $ */ +/* $NetBSD: sysctl.h,v 1.102 2003/12/06 04:16:33 atatat Exp $ */ /* * Copyright (c) 1989, 1993 @@ -717,7 +717,8 @@ struct kinfo_drivers { #define PROC_PID_LIMIT 2 #define PROC_PID_STOPFORK 3 #define PROC_PID_STOPEXEC 4 -#define PROC_PID_MAXID 5 +#define PROC_PID_STOPEXIT 5 +#define PROC_PID_MAXID 6 #define PROC_PID_NAMES { \ { 0, 0 }, \ @@ -725,6 +726,7 @@ struct kinfo_drivers { { "rlimit", CTLTYPE_NODE }, \ { "stopfork", CTLTYPE_INT }, \ { "stopexec", CTLTYPE_INT }, \ + { "stopexit", CTLTYPE_INT }, \ } /* Limit types from */