diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-03-10 05:54:29 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-03-10 05:54:29 +0000 |
commit | d61a690bb1fb3482ac59dcc5921f333753c82a6b (patch) | |
tree | 5466be7ac0a9565271594703bd4295fed7f37092 /sys/kern | |
parent | b379a7cafedd0ac7b6d970219ab48a3a32e18feb (diff) |
Add PS_EXITING to better differentiate between the process exiting and
the main thread exiting. c.f. regress/sys/kern/main-thread-exited/
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_event.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_exit.c | 3 | ||||
-rw-r--r-- | sys/kern/kern_sig.c | 7 | ||||
-rw-r--r-- | sys/kern/kern_sysctl.c | 8 | ||||
-rw-r--r-- | sys/kern/kern_time.c | 4 | ||||
-rw-r--r-- | sys/kern/sys_process.c | 4 |
6 files changed, 16 insertions, 14 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index d247058b9b0..37753d694b9 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_event.c,v 1.42 2012/02/15 04:26:27 guenther Exp $ */ +/* $OpenBSD: kern_event.c,v 1.43 2012/03/10 05:54:28 guenther Exp $ */ /*- * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> @@ -199,7 +199,7 @@ filt_procattach(struct knote *kn) return (ESRCH); /* threads and exiting processes can't be specified */ - if (p->p_flag & (P_THREAD|P_WEXIT)) + if (p->p_flag & P_THREAD || p->p_p->ps_flags & PS_EXITING) return (ESRCH); /* diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 89f4fa423fc..c9a2a9c93f0 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.107 2012/02/20 22:23:39 guenther Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.108 2012/03/10 05:54:28 guenther Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -140,6 +140,7 @@ exit1(struct proc *p, int rv, int flags) } if (flags == EXIT_NORMAL) { + atomic_setbits_int(&pr->ps_flags, PS_EXITING); pr->ps_mainproc->p_xstat = rv; /* diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index e3ec6386bc0..9ab09b72920 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.134 2012/02/20 22:23:39 guenther Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.135 2012/03/10 05:54:28 guenther Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -756,7 +756,7 @@ ptsignal(struct proc *p, int signum, enum signal_type type) int s, prop; sig_t action; int mask; - struct process *pr; + struct process *pr = p->p_p; struct proc *q; int wakeparent = 0; @@ -766,12 +766,11 @@ ptsignal(struct proc *p, int signum, enum signal_type type) #endif /* Ignore signal if we are exiting */ - if (p->p_flag & P_WEXIT) + if (pr->ps_flags & PS_EXITING) return; mask = sigmask(signum); - pr = p->p_p; if (type == SPROCESS) { /* * A process-wide signal can be diverted to a different diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 9fc8513424f..e4004860236 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.214 2012/02/20 22:23:39 guenther Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.215 2012/03/10 05:54:28 guenther Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -1286,6 +1286,7 @@ sysctl_file2(int *name, u_int namelen, char *where, size_t *sizep, LIST_FOREACH(pp, &allproc, p_list) { /* skip system, exiting, embryonic and undead processes */ if ((pp->p_flag & P_SYSTEM) || (pp->p_flag & P_WEXIT) + || (pp->p_p->ps_flags & PS_EXITING) || pp->p_stat == SIDL || pp->p_stat == SZOMB) continue; if (arg > 0 && pp->p_pid != (pid_t)arg) { @@ -1314,6 +1315,7 @@ sysctl_file2(int *name, u_int namelen, char *where, size_t *sizep, LIST_FOREACH(pp, &allproc, p_list) { /* skip system, exiting, embryonic and undead processes */ if ((pp->p_flag & P_SYSTEM) || (pp->p_flag & P_WEXIT) + || (pp->p_p->ps_flags & PS_EXITING) || pp->p_stat == SIDL || pp->p_stat == SZOMB) continue; if (arg > 0 && pp->p_ucred->cr_uid != (uid_t)arg) { @@ -1580,7 +1582,7 @@ sysctl_proc_args(int *name, u_int namelen, void *oldp, size_t *oldlenp, return (EINVAL); /* Exiting - don't bother, it will be gone soon anyway */ - if ((vp->p_flag & P_WEXIT)) + if (vp->p_p->ps_flags & PS_EXITING) return (ESRCH); /* Execing - danger. */ @@ -1768,7 +1770,7 @@ sysctl_proc_cwd(int *name, u_int namelen, void *oldp, size_t *oldlenp, return (error); /* Exiting - don't bother, it will be gone soon anyway */ - if (findp->p_flag & P_WEXIT) + if (findp->p_p->ps_flags & PS_EXITING) return (ESRCH); len = *oldlenp; diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index db6625040a7..3d2d36f4af9 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_time.c,v 1.71 2010/06/30 01:47:35 tedu Exp $ */ +/* $OpenBSD: kern_time.c,v 1.72 2012/03/10 05:54:28 guenther Exp $ */ /* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */ /* @@ -705,7 +705,7 @@ realitexpire(void *arg) timo = tvtohz(&ntv) - 1; if (timo <= 0) timo = 1; - if ((p->p_flag & P_WEXIT) == 0) + if ((p->p_p->ps_flags & PS_EXITING) == 0) timeout_add(&p->p_realit_to, timo); return; } diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 57b761f2483..79ee654ac55 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_process.c,v 1.50 2012/02/25 16:45:03 miod Exp $ */ +/* $OpenBSD: sys_process.c,v 1.51 2012/03/10 05:54:28 guenther Exp $ */ /* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */ /*- @@ -687,7 +687,7 @@ process_domem(struct proc *curp, struct proc *p, struct uio *uio, int req) return (error); /* XXXCDC: how should locking work here? */ - if ((p->p_flag & P_WEXIT) || (p->p_vmspace->vm_refcnt < 1)) + if ((p->p_p->ps_flags & PS_EXITING) || (p->p_vmspace->vm_refcnt < 1)) return(EFAULT); addr = uio->uio_offset; |