The missing pieces of PROC_PID_STOPEXIT/P_STOPEXIT, a sysctl tweakable

flag that makes a process stop as it exits.
This commit is contained in:
atatat 2003-12-06 04:16:33 +00:00
parent 23293f9bae
commit 44f5f6b89b
3 changed files with 20 additions and 5 deletions

View File

@ -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 <sys/cdefs.h>
__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));
/*

View File

@ -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.

View File

@ -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 <sys/resources.h> */