From: guenther Date: Thu, 15 May 2014 04:43:25 +0000 (+0000) Subject: knote_processexit() needs the thread to pass down to FRELE(), so pass it X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=67330adf71d698fcd3519ee44d012fbf72268b9a;p=openbsd knote_processexit() needs the thread to pass down to FRELE(), so pass it the exiting thread instead of assuming that that's ps_mainproc. Also, panic no matter which thread of init takes it down. ok tedu@ --- diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 5b1122ddf56..15cc3c50491 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_event.c,v 1.56 2014/03/30 21:54:48 guenther Exp $ */ +/* $OpenBSD: kern_event.c,v 1.57 2014/05/15 04:43:25 guenther Exp $ */ /*- * Copyright (c) 1999,2000,2001 Jonathan Lemon @@ -993,12 +993,14 @@ knote_fdclose(struct proc *p, int fd) * XXX this could be more efficient, doing a single pass down the klist */ void -knote_processexit(struct process *pr) +knote_processexit(struct proc *p) { + struct process *pr = p->p_p; + KNOTE(&pr->ps_klist, NOTE_EXIT); /* remove other knotes hanging off the process */ - knote_remove(pr->ps_mainproc, &pr->ps_klist); + knote_remove(p, &pr->ps_klist); } void diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 1fbaa8649ff..b7326c63517 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.141 2014/05/15 03:52:25 guenther Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.142 2014/05/15 04:43:25 guenther Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -117,10 +117,6 @@ exit1(struct proc *p, int rv, int flags) struct process *pr, *qr, *nqr; struct rusage *rup; struct vnode *ovp; - - if (p->p_pid == 1) - panic("init died (signal %d, exit %d)", - WTERMSIG(rv), WEXITSTATUS(rv)); atomic_setbits_int(&p->p_flag, P_WEXIT); @@ -139,6 +135,10 @@ exit1(struct proc *p, int rv, int flags) } if (flags == EXIT_NORMAL) { + if (pr->ps_pid == 1) + panic("init died (signal %d, exit %d)", + WTERMSIG(rv), WEXITSTATUS(rv)); + atomic_setbits_int(&pr->ps_flags, PS_EXITING); pr->ps_mainproc->p_xstat = rv; @@ -331,7 +331,7 @@ exit1(struct proc *p, int rv, int flags) ruadd(rup, &pr->ps_cru); /* notify interested parties of our demise and clean up */ - knote_processexit(pr); + knote_processexit(p); /* * Notify parent that we're gone. If we're not going to diff --git a/sys/sys/event.h b/sys/sys/event.h index 2a488448af8..d0523a7f858 100644 --- a/sys/sys/event.h +++ b/sys/sys/event.h @@ -1,4 +1,4 @@ -/* $OpenBSD: event.h,v 1.19 2013/08/13 05:52:26 guenther Exp $ */ +/* $OpenBSD: event.h,v 1.20 2014/05/15 04:43:25 guenther Exp $ */ /*- * Copyright (c) 1999,2000,2001 Jonathan Lemon @@ -170,7 +170,7 @@ extern void knote(struct klist *list, long hint); extern void knote_activate(struct knote *); extern void knote_remove(struct proc *p, struct klist *list); extern void knote_fdclose(struct proc *p, int fd); -extern void knote_processexit(struct process *); +extern void knote_processexit(struct proc *); extern int kqueue_register(struct kqueue *kq, struct kevent *kev, struct proc *p); extern int filt_seltrue(struct knote *kn, long hint);