Diff below moves some job control bits out of exit1(). It is extracted from guenther@'s proctreelk diff. It's currently a noop so I'd like to get it in to reduce the locking diff.
ok? Index: kern/kern_exit.c =================================================================== RCS file: /cvs/src/sys/kern/kern_exit.c,v retrieving revision 1.163 diff -u -p -r1.163 kern_exit.c --- kern/kern_exit.c 30 Dec 2017 20:47:00 -0000 1.163 +++ kern/kern_exit.c 9 Feb 2018 20:27:17 -0000 @@ -117,8 +117,7 @@ exit1(struct proc *p, int rv, int flags) { struct process *pr, *qr, *nqr; struct rusage *rup; - struct vnode *ovp; - + atomic_setbits_int(&p->p_flag, P_WEXIT); pr = p->p_p; @@ -184,44 +183,7 @@ exit1(struct proc *p, int rv, int flags) #ifdef SYSVSEM semexit(pr); #endif - if (SESS_LEADER(pr)) { - struct session *sp = pr->ps_session; - - if (sp->s_ttyvp) { - /* - * Controlling process. - * Signal foreground pgrp, - * drain controlling terminal - * and revoke access to controlling terminal. - */ - if (sp->s_ttyp->t_session == sp) { - if (sp->s_ttyp->t_pgrp) - pgsignal(sp->s_ttyp->t_pgrp, - SIGHUP, 1); - ttywait(sp->s_ttyp); - /* - * The tty could have been revoked - * if we blocked. - */ - if (sp->s_ttyvp) - VOP_REVOKE(sp->s_ttyvp, - REVOKEALL); - } - ovp = sp->s_ttyvp; - sp->s_ttyvp = NULL; - if (ovp) - vrele(ovp); - /* - * s_ttyp is not zero'd; we use this to - * indicate that the session once had a - * controlling terminal. (for logging and - * informational purposes) - */ - } - sp->s_leader = NULL; - } - fixjobc(pr, pr->ps_pgrp, 0); - + killjobc(pr); #ifdef ACCOUNTING acct_process(p); #endif Index: kern/kern_proc.c =================================================================== RCS file: /cvs/src/sys/kern/kern_proc.c,v retrieving revision 1.79 diff -u -p -r1.79 kern_proc.c --- kern/kern_proc.c 30 Dec 2017 20:47:00 -0000 1.79 +++ kern/kern_proc.c 9 Feb 2018 20:26:55 -0000 @@ -47,6 +47,7 @@ #include <sys/tty.h> #include <sys/signalvar.h> #include <sys/pool.h> +#include <sys/vnode.h> #define UIHASH(uid) (&uihashtbl[(uid) & uihash]) LIST_HEAD(uihashhead, uidinfo) *uihashtbl; @@ -380,6 +381,48 @@ fixjobc(struct process *pr, struct pgrp else if (--hispgrp->pg_jobc == 0) orphanpg(hispgrp); } +} + +void +killjobc(struct process *pr) +{ + if (SESS_LEADER(pr)) { + struct session *sp = pr->ps_session; + + if (sp->s_ttyvp) { + struct vnode *ovp; + + /* + * Controlling process. + * Signal foreground pgrp, + * drain controlling terminal + * and revoke access to controlling terminal. + */ + if (sp->s_ttyp->t_session == sp) { + if (sp->s_ttyp->t_pgrp) + pgsignal(sp->s_ttyp->t_pgrp, SIGHUP, 1); + ttywait(sp->s_ttyp); + /* + * The tty could have been revoked + * if we blocked. + */ + if (sp->s_ttyvp) + VOP_REVOKE(sp->s_ttyvp, REVOKEALL); + } + ovp = sp->s_ttyvp; + sp->s_ttyvp = NULL; + if (ovp) + vrele(ovp); + /* + * s_ttyp is not zero'd; we use this to + * indicate that the session once had a + * controlling terminal. (for logging and + * informational purposes) + */ + } + sp->s_leader = NULL; + } + fixjobc(pr, pr->ps_pgrp, 0); } /* Index: sys/proc.h =================================================================== RCS file: /cvs/src/sys/sys/proc.h,v retrieving revision 1.244 diff -u -p -r1.244 proc.h --- sys/proc.h 19 Dec 2017 10:04:59 -0000 1.244 +++ sys/proc.h 9 Feb 2018 20:24:30 -0000 @@ -500,6 +500,7 @@ int enterpgrp(struct process *, pid_t, s void fixjobc(struct process *, struct pgrp *, int); int inferior(struct process *, struct process *); void leavepgrp(struct process *); +void killjobc(struct process *); void preempt(void); void pgdelete(struct pgrp *); void procinit(void);