* Make process 'parent' the new parent of process 'child'. * Must be called with an exclusive hold of proctree lock. */
| 1376 | * Must be called with an exclusive hold of proctree lock. |
| 1377 | */ |
| 1378 | void |
| 1379 | proc_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 | } |
no test coverage detected