summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2018-02-10 10:32:52 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2018-02-10 10:32:52 +0000
commit89bb1d97d89650c6e3781f1a1f43966cddf715de (patch)
tree864b1222d4bd01670b15b620ac314aa0041c566c /sys
parent9e225bd8aced6a2d6f5f72da97216afbadafd635 (diff)
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')
-rw-r--r--sys/kern/kern_exit.c44
-rw-r--r--sys/kern/kern_proc.c45
-rw-r--r--sys/sys/proc.h3
3 files changed, 49 insertions, 43 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index a104c292386..dfd4e38078f 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exit.c,v 1.163 2017/12/30 20:47:00 guenther Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.164 2018/02/10 10:32:51 mpi Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@@ -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
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,
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index d73e6aaa60a..e79adb5972e 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.h,v 1.244 2017/12/19 10:04:59 stefan Exp $ */
+/* $OpenBSD: proc.h,v 1.245 2018/02/10 10:32:51 mpi Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
@@ -500,6 +500,7 @@ int enterpgrp(struct process *, pid_t, struct pgrp *, struct session *);
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);