257 error = as_dup(p->p_as, cp);
258 if (error != 0) {
259 mutex_enter(&p->p_lock);
260 sprunlock(p);
261 fork_fail(cp);
262 mutex_enter(&pidlock);
263 orphpp = &p->p_orphan;
264 while (*orphpp != cp)
265 orphpp = &(*orphpp)->p_nextorph;
266 *orphpp = cp->p_nextorph;
267 if (p->p_child == cp)
268 p->p_child = cp->p_sibling;
269 if (cp->p_sibling)
270 cp->p_sibling->p_psibling = cp->p_psibling;
271 if (cp->p_psibling)
272 cp->p_psibling->p_sibling = cp->p_sibling;
273 mutex_enter(&cp->p_lock);
274 tk = cp->p_task;
275 task_detach(cp);
276 ASSERT(cp->p_pool->pool_ref > 0);
277 atomic_add_32(&cp->p_pool->pool_ref, -1);
278 mutex_exit(&cp->p_lock);
279 pid_exit(cp, tk);
280 mutex_exit(&pidlock);
281 task_rele(tk);
282
283 mutex_enter(&p->p_lock);
284 p->p_flag &= ~SFORKING;
285 pool_barrier_exit();
286 continuelwps(p);
287 mutex_exit(&p->p_lock);
288 /*
289 * Preserve ENOMEM error condition but
290 * map all others to EAGAIN.
291 */
292 error = (error == ENOMEM) ? ENOMEM : EAGAIN;
293 goto forkerr;
294 }
295
296 /*
297 * Remove all DTrace tracepoints from the child process. We
611 cp->p_lwpdir_sz = 0;
612
613 if (cp->p_tidhash)
614 kmem_free(cp->p_tidhash,
615 cp->p_tidhash_sz * sizeof (*cp->p_tidhash));
616 cp->p_tidhash = NULL;
617 cp->p_tidhash_sz = 0;
618
619 forklwp_fail(cp);
620 fork_fail(cp);
621 rctl_set_free(cp->p_rctls);
622 mutex_enter(&pidlock);
623
624 /*
625 * Detach failed child from task.
626 */
627 mutex_enter(&cp->p_lock);
628 tk = cp->p_task;
629 task_detach(cp);
630 ASSERT(cp->p_pool->pool_ref > 0);
631 atomic_add_32(&cp->p_pool->pool_ref, -1);
632 mutex_exit(&cp->p_lock);
633
634 orphpp = &p->p_orphan;
635 while (*orphpp != cp)
636 orphpp = &(*orphpp)->p_nextorph;
637 *orphpp = cp->p_nextorph;
638 if (p->p_child == cp)
639 p->p_child = cp->p_sibling;
640 if (cp->p_sibling)
641 cp->p_sibling->p_psibling = cp->p_psibling;
642 if (cp->p_psibling)
643 cp->p_psibling->p_sibling = cp->p_sibling;
644 pid_exit(cp, tk);
645 mutex_exit(&pidlock);
646
647 task_rele(tk);
648
649 mutex_enter(&p->p_lock);
650 pool_barrier_exit();
651 continuelwps(p);
1111 cp->p_nextofkin = pp;
1112 pp->p_orphan = cp;
1113
1114 /*
1115 * Inherit profiling state; do not inherit REALPROF profiling state.
1116 */
1117 cp->p_prof = pp->p_prof;
1118 cp->p_rprof_cyclic = CYCLIC_NONE;
1119
1120 /*
1121 * Inherit pool pointer from the parent. Kernel processes are
1122 * always bound to the default pool.
1123 */
1124 mutex_enter(&pp->p_lock);
1125 if (flags & GETPROC_KERNEL) {
1126 cp->p_pool = pool_default;
1127 cp->p_flag |= SSYS;
1128 } else {
1129 cp->p_pool = pp->p_pool;
1130 }
1131 atomic_add_32(&cp->p_pool->pool_ref, 1);
1132 mutex_exit(&pp->p_lock);
1133
1134 /*
1135 * Add the child process to the current task. Kernel processes
1136 * are always attached to task0.
1137 */
1138 mutex_enter(&cp->p_lock);
1139 if (flags & GETPROC_KERNEL)
1140 task_attach(task0p, cp);
1141 else
1142 task_attach(pp->p_task, cp);
1143 mutex_exit(&cp->p_lock);
1144 mutex_exit(&pidlock);
1145
1146 avl_create(&cp->p_ct_held, contract_compar, sizeof (contract_t),
1147 offsetof(contract_t, ct_ctlist));
1148
1149 /*
1150 * Duplicate any audit information kept in the process table
1151 */
|
257 error = as_dup(p->p_as, cp);
258 if (error != 0) {
259 mutex_enter(&p->p_lock);
260 sprunlock(p);
261 fork_fail(cp);
262 mutex_enter(&pidlock);
263 orphpp = &p->p_orphan;
264 while (*orphpp != cp)
265 orphpp = &(*orphpp)->p_nextorph;
266 *orphpp = cp->p_nextorph;
267 if (p->p_child == cp)
268 p->p_child = cp->p_sibling;
269 if (cp->p_sibling)
270 cp->p_sibling->p_psibling = cp->p_psibling;
271 if (cp->p_psibling)
272 cp->p_psibling->p_sibling = cp->p_sibling;
273 mutex_enter(&cp->p_lock);
274 tk = cp->p_task;
275 task_detach(cp);
276 ASSERT(cp->p_pool->pool_ref > 0);
277 atomic_dec_32(&cp->p_pool->pool_ref);
278 mutex_exit(&cp->p_lock);
279 pid_exit(cp, tk);
280 mutex_exit(&pidlock);
281 task_rele(tk);
282
283 mutex_enter(&p->p_lock);
284 p->p_flag &= ~SFORKING;
285 pool_barrier_exit();
286 continuelwps(p);
287 mutex_exit(&p->p_lock);
288 /*
289 * Preserve ENOMEM error condition but
290 * map all others to EAGAIN.
291 */
292 error = (error == ENOMEM) ? ENOMEM : EAGAIN;
293 goto forkerr;
294 }
295
296 /*
297 * Remove all DTrace tracepoints from the child process. We
611 cp->p_lwpdir_sz = 0;
612
613 if (cp->p_tidhash)
614 kmem_free(cp->p_tidhash,
615 cp->p_tidhash_sz * sizeof (*cp->p_tidhash));
616 cp->p_tidhash = NULL;
617 cp->p_tidhash_sz = 0;
618
619 forklwp_fail(cp);
620 fork_fail(cp);
621 rctl_set_free(cp->p_rctls);
622 mutex_enter(&pidlock);
623
624 /*
625 * Detach failed child from task.
626 */
627 mutex_enter(&cp->p_lock);
628 tk = cp->p_task;
629 task_detach(cp);
630 ASSERT(cp->p_pool->pool_ref > 0);
631 atomic_dec_32(&cp->p_pool->pool_ref);
632 mutex_exit(&cp->p_lock);
633
634 orphpp = &p->p_orphan;
635 while (*orphpp != cp)
636 orphpp = &(*orphpp)->p_nextorph;
637 *orphpp = cp->p_nextorph;
638 if (p->p_child == cp)
639 p->p_child = cp->p_sibling;
640 if (cp->p_sibling)
641 cp->p_sibling->p_psibling = cp->p_psibling;
642 if (cp->p_psibling)
643 cp->p_psibling->p_sibling = cp->p_sibling;
644 pid_exit(cp, tk);
645 mutex_exit(&pidlock);
646
647 task_rele(tk);
648
649 mutex_enter(&p->p_lock);
650 pool_barrier_exit();
651 continuelwps(p);
1111 cp->p_nextofkin = pp;
1112 pp->p_orphan = cp;
1113
1114 /*
1115 * Inherit profiling state; do not inherit REALPROF profiling state.
1116 */
1117 cp->p_prof = pp->p_prof;
1118 cp->p_rprof_cyclic = CYCLIC_NONE;
1119
1120 /*
1121 * Inherit pool pointer from the parent. Kernel processes are
1122 * always bound to the default pool.
1123 */
1124 mutex_enter(&pp->p_lock);
1125 if (flags & GETPROC_KERNEL) {
1126 cp->p_pool = pool_default;
1127 cp->p_flag |= SSYS;
1128 } else {
1129 cp->p_pool = pp->p_pool;
1130 }
1131 atomic_inc_32(&cp->p_pool->pool_ref);
1132 mutex_exit(&pp->p_lock);
1133
1134 /*
1135 * Add the child process to the current task. Kernel processes
1136 * are always attached to task0.
1137 */
1138 mutex_enter(&cp->p_lock);
1139 if (flags & GETPROC_KERNEL)
1140 task_attach(task0p, cp);
1141 else
1142 task_attach(pp->p_task, cp);
1143 mutex_exit(&cp->p_lock);
1144 mutex_exit(&pidlock);
1145
1146 avl_create(&cp->p_ct_held, contract_compar, sizeof (contract_t),
1147 offsetof(contract_t, ct_ctlist));
1148
1149 /*
1150 * Duplicate any audit information kept in the process table
1151 */
|