MCPcopy Create free account
hub / github.com/F-Stack/f-stack / proc_reparent

Function proc_reparent

freebsd/kern/kern_exit.c:1378–1401  ·  view source on GitHub ↗

* Make process 'parent' the new parent of process 'child'. * Must be called with an exclusive hold of proctree lock. */

Source from the content-addressed store, hash-verified

1376 * Must be called with an exclusive hold of proctree lock.
1377 */
1378void
1379proc_reparent(struct proc *child, struct proc *parent, bool set_oppid)
1380{
1381
1382 sx_assert(&proctree_lock, SX_XLOCKED);
1383 PROC_LOCK_ASSERT(child, MA_OWNED);
1384 if (child->p_pptr == parent)
1385 return;
1386
1387 PROC_LOCK(child->p_pptr);
1388 sigqueue_take(child->p_ksi);
1389 PROC_UNLOCK(child->p_pptr);
1390 LIST_REMOVE(child, p_sibling);
1391 LIST_INSERT_HEAD(&parent->p_children, child, p_sibling);
1392
1393 proc_clear_orphan(child);
1394 if ((child->p_flag & P_TRACED) != 0) {
1395 proc_add_orphan(child, child->p_pptr);
1396 }
1397
1398 child->p_pptr = parent;
1399 if (set_oppid)
1400 child->p_oppid = parent->p_pid;
1401}

Callers 7

do_forkFunction · 0.85
kern_ptraceFunction · 0.85
reaper_abandon_childrenFunction · 0.85
exit1Function · 0.85
proc_reapFunction · 0.85
procdesc_closeFunction · 0.85
kproc_exitFunction · 0.85

Calls 3

sigqueue_takeFunction · 0.85
proc_clear_orphanFunction · 0.85
proc_add_orphanFunction · 0.85

Tested by

no test coverage detected