svn commit: r352180 - in stable/12/sys: kern sys
Mariusz Zaborski
oshogbo at FreeBSD.org
Tue Sep 10 20:15:53 UTC 2019
Author: oshogbo
Date: Tue Sep 10 20:15:52 2019
New Revision: 352180
URL: https://svnweb.freebsd.org/changeset/base/352180
Log:
MFCr350611:
proc: introduce the proc_add_orphan function
This API allows adding the process to its parent orphan list.
Reviewed by: kib, markj
Modified:
stable/12/sys/kern/kern_exit.c
stable/12/sys/sys/proc.h
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/kern/kern_exit.c
==============================================================================
--- stable/12/sys/kern/kern_exit.c Tue Sep 10 20:14:52 2019 (r352179)
+++ stable/12/sys/kern/kern_exit.c Tue Sep 10 20:15:52 2019 (r352180)
@@ -1330,6 +1330,24 @@ loop_locked:
goto loop;
}
+void
+proc_add_orphan(struct proc *child, struct proc *parent)
+{
+
+ sx_assert(&proctree_lock, SX_XLOCKED);
+ KASSERT((child->p_flag & P_TRACED) != 0,
+ ("proc_add_orphan: not traced"));
+
+ if (LIST_EMPTY(&parent->p_orphans)) {
+ child->p_treeflag |= P_TREE_FIRST_ORPHAN;
+ LIST_INSERT_HEAD(&parent->p_orphans, child, p_orphan);
+ } else {
+ LIST_INSERT_AFTER(LIST_FIRST(&parent->p_orphans),
+ child, p_orphan);
+ }
+ child->p_treeflag |= P_TREE_ORPHANED;
+}
+
/*
* Make process 'parent' the new parent of process 'child'.
* Must be called with an exclusive hold of proctree lock.
@@ -1350,16 +1368,8 @@ proc_reparent(struct proc *child, struct proc *parent,
LIST_INSERT_HEAD(&parent->p_children, child, p_sibling);
clear_orphan(child);
- if (child->p_flag & P_TRACED) {
- if (LIST_EMPTY(&child->p_pptr->p_orphans)) {
- child->p_treeflag |= P_TREE_FIRST_ORPHAN;
- LIST_INSERT_HEAD(&child->p_pptr->p_orphans, child,
- p_orphan);
- } else {
- LIST_INSERT_AFTER(LIST_FIRST(&child->p_pptr->p_orphans),
- child, p_orphan);
- }
- child->p_treeflag |= P_TREE_ORPHANED;
+ if ((child->p_flag & P_TRACED) != 0) {
+ proc_add_orphan(child, child->p_pptr);
}
child->p_pptr = parent;
Modified: stable/12/sys/sys/proc.h
==============================================================================
--- stable/12/sys/sys/proc.h Tue Sep 10 20:14:52 2019 (r352179)
+++ stable/12/sys/sys/proc.h Tue Sep 10 20:15:52 2019 (r352180)
@@ -1063,6 +1063,7 @@ void proc_linkup(struct proc *p, struct thread *td);
struct proc *proc_realparent(struct proc *child);
void proc_reap(struct thread *td, struct proc *p, int *status, int options);
void proc_reparent(struct proc *child, struct proc *newparent, bool set_oppid);
+void proc_add_orphan(struct proc *child, struct proc *parent);
void proc_set_traced(struct proc *p, bool stop);
void proc_wkilled(struct proc *p);
struct pstats *pstats_alloc(void);
More information about the svn-src-all
mailing list