diff options
| author | 2018-02-10 10:32:51 +0000 | |
|---|---|---|
| committer | 2018-02-10 10:32:51 +0000 | |
| commit | c33efb0726281535972115f69ef65cd8bc3854d2 (patch) | |
| tree | 4065c76fbb335197291107bf99547d4bae6e4634 /sys/kern/kern_proc.c | |
| parent | Revert previous & incorrect NULL dereference fix. (diff) | |
| download | wireguard-openbsd-c33efb0726281535972115f69ef65cd8bc3854d2.tar.xz wireguard-openbsd-c33efb0726281535972115f69ef65cd8bc3854d2.zip | |
Move cleanup job control bits to their own function.
Part of the larger 'proctreelk' diff from guenther@
No functional change, ok benno@, tedu@
Diffstat (limited to 'sys/kern/kern_proc.c')
| -rw-r--r-- | sys/kern/kern_proc.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index e156fa6629a..7ca14325220 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_proc.c,v 1.79 2017/12/30 20:47:00 guenther Exp $ */ +/* $OpenBSD: kern_proc.c,v 1.80 2018/02/10 10:32:51 mpi Exp $ */ /* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */ /* @@ -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; @@ -382,6 +383,48 @@ fixjobc(struct process *pr, struct pgrp *pgrp, int entering) } } +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); +} + /* * A process group has become orphaned; * if there are any stopped processes in the group, |
