Lines Matching defs:child
135 void thread_set_child(thread_t child, int pid);
142 thread_t procdup(proc_t parent, proc_t child);
143 thread_t fork_create_child(task_t parent_task, proc_t child, int inherit_memory, int is64bit);
156 * Retval: 0 (to child process)
157 * !0 pid of child (to parent process)
165 * has its task, thread, and uthread lent to the child process,
168 * is effectively running on the child process.
171 * though discouraged, and will operate on the child process; any
173 * changes in the parent state, and, if inheritable, the child
175 * child process at execve() time, will also be effected. Given
182 proc_t child;
246 if ((child = forkproc(parent,1)) == NULL) {
251 * XXX these are inherited by the child, which depends on
263 /* that we referenced from the parent ... with the child */
267 mac_cred_label_associate_fork(child->p_ucred, child);
270 AUDIT_ARG(pid, child->p_pid);
272 child->task = parent->task;
274 /* make child visible */
275 pinsertchild(parent, child);
277 child->p_lflag |= P_LINVFORK;
278 child->p_vforkact = cur_act;
279 child->p_stat = SRUN;
282 ut->uu_proc = child;
292 thread_set_child(cur_act, child->p_pid);
294 microtime(&child->p_start);
295 microtime(&child->p_stats->p_start); /* for compat sake */
296 child->p_acflag = AFORK;
300 * child to exec or exit, set P_PPWAIT on child, and sleep on our
303 child->p_lflag |= P_LPPWAIT;
305 /* drop the signal lock on the child */
306 proc_signalend(child, 0);
307 proc_transend(child, 0);
309 retval[0] = child->p_pid;
310 retval[1] = 1; /* flag child return for user space */
312 DTRACE_PROC1(create, proc_t, child);
324 * Parameters: child Child process
334 vfork_return(proc_t child, register_t *retval, int rval)
336 proc_t parent = child->p_pptr;
361 child->p_lflag &= ~P_LINVFORK;
362 child->p_vforkact = (void *)0;
378 * Description: Common operations associated with the creation of a child
382 * child child process
384 * to be inherited by the child
385 * is64bit TRUE, if the child being created will
396 * process 'child'. If the parent process address space is to
398 * task should inherit this from the child task.
405 fork_create_child(task_t parent_task, proc_t child, int inherit_memory, int is64bit)
411 /* Create a new task for the child process */
421 /* Set the child task to the new task */
422 child->task = child_task;
424 /* Set child task proc to child proc */
425 set_bsdtask_info(child_task, child);
428 if (timerisset(&child->p_rlim_cpu))
439 /* valid to use p_ucred as child is still not running ... */
440 mac_task_label_update_cred(child->p_ucred, child_task);
443 /* Set child scheduler priority if nice value inherited from parent */
444 if (child->p_nice != 0)
445 resetpriority(child);
447 /* Create a new thread for the child process */
465 * for a child process of that parent.
468 * child Child process to duplicate into
494 procdup(proc_t parent, proc_t child)
500 child_thread = fork_create_child(TASK_NULL, child, FALSE, FALSE);
502 child_thread = fork_create_child(parent->task, child, TRUE, (parent->p_flag & P_LP64));
508 OSBitOrAtomic(P_LP64, (UInt32 *)&child->p_flag);
520 OSBitAndAtomic(~((uint32_t)P_LP64), (UInt32 *)&child->p_flag);
543 proc_t child;
602 /* child = newth->task->proc; */
603 child = (proc_t)(get_bsdtask_info(get_threadtask(newth)));
607 /* safe to use p_ucred here since child is not running */
611 mac_cred_label_associate_fork(child->p_ucred, child);
615 set_security_token(child);
617 AUDIT_ARG(pid, child->p_pid);
619 thread_set_child(newth, child->p_pid);
621 microtime(&child->p_start);
622 microtime(&child->p_stats->p_start); /* for compat sake */
623 child->p_acflag = AFORK;
634 * Remove all DTrace tracepoints from the child process. We
639 dtrace_fasttrap_fork(parent, child);
652 * fail to copy the helpers to the child process.
654 dtrace_lazy_dofs_duplicate(parent, child);
659 * sprlock() may fail because the child is being forked.
663 * never fails to find the child. We do not set SFORKING.
666 (*dtrace_helpers_fork)(parent, child);
671 /* drop the signal lock on the child */
672 proc_signalend(child, 0);
673 proc_transend(child, 0);
675 /* "Return" to the child */
684 proc_knote(parent, NOTE_FORK | child->p_pid);
686 retval[0] = child->p_pid;
689 DTRACE_PROC1(create, proc_t, child);
704 * Returns: !NULL pointer to new child thread
707 * Note: On return newly created child process has signal lock held
722 proc_t child;
725 if ((child = forkproc(parent,lock)) == NULL) {
730 if ((th = procdup(parent, child)) == NULL) {
735 forkproc_free(child, lock);
739 /* make child visible */
740 pinsertchild(parent, child);
743 * Make child runnable, set start time.
745 child->p_stat = SRUN;
852 struct proc * child; /* Our new process */
858 MALLOC_ZONE(child, proc_t , sizeof *child, M_PROC, M_WAITOK);
859 if (child == NULL) {
864 bzero(child, sizeof *child);
866 MALLOC_ZONE(child->p_stats, struct pstats *,
867 sizeof *child->p_stats, M_PSTATS, M_WAITOK);
868 if (child->p_stats == NULL) {
870 FREE_ZONE(child, sizeof *child, M_PROC);
871 child = NULL;
874 MALLOC_ZONE(child->p_sigacts, struct sigacts *,
875 sizeof *child->p_sigacts, M_SIGACTS, M_WAITOK);
876 if (child->p_sigacts == NULL) {
878 FREE_ZONE(child->p_stats, sizeof *child->p_stats, M_PSTATS);
879 FREE_ZONE(child, sizeof *child, M_PROC);
880 child = NULL;
883 child->p_rcall = thread_call_allocate((thread_call_func_t)realitexpire, child);
884 if (child->p_rcall == NULL) {
885 FREE_ZONE(child->p_sigacts, sizeof *child->p_sigacts, M_SIGACTS);
886 FREE_ZONE(child->p_stats, sizeof *child->p_stats, M_PSTATS);
887 FREE_ZONE(child, sizeof *child, M_PROC);
888 child = NULL;
928 child->p_pid = nextpid;
929 child->p_idversion = nextpidversion++;
931 if (child->p_pid != 0) {
932 if (pfind_locked(child->p_pid) != PROC_NULL)
937 child->p_listflag |= (P_LIST_INHASH | P_LIST_INCREATE);
938 LIST_INSERT_HEAD(PIDHASH(child->p_pid), child, p_hash);
946 child->p_stat = SIDL;
947 child->p_pgrpid = PGRPID_DEAD;
953 bcopy(&parent->p_startcopy, &child->p_startcopy,
954 (unsigned) ((caddr_t)&child->p_endcopy - (caddr_t)&child->p_startcopy));
962 child->p_flag = (parent->p_flag & (P_LP64 | P_TRANSLATED | P_AFFINITY));
964 startprofclock(child);
969 child->p_ucred = kauth_cred_get_with_ref();
971 lck_mtx_init(&child->p_mlock, proc_lck_grp, proc_lck_attr);
972 lck_mtx_init(&child->p_fdmlock, proc_lck_grp, proc_lck_attr);
974 lck_mtx_init(&child->p_dtrace_sprlock, proc_lck_grp, proc_lck_attr);
976 lck_spin_init(&child->p_slock, proc_lck_grp, proc_lck_attr);
977 klist_init(&child->p_klist);
979 if (child->p_textvp != NULLVP) {
982 if (vnode_getwithref(child->p_textvp) == 0) {
983 error = vnode_ref(child->p_textvp);
984 vnode_put(child->p_textvp);
986 child->p_textvp = NULLVP;
990 /* XXX may fail to copy descriptors to child */
991 child->p_fd = fdcopy(parent, uth_parent->uu_cdir);
995 /* XXX may fail to attach shm to child */
996 (void)shmfork(parent,child);
1000 * inherit the limit structure to child
1002 proc_limitfork(parent, child);
1004 if (child->p_limit->pl_rlimit[RLIMIT_CPU].rlim_cur != RLIM_INFINITY) {
1005 uint64_t rlim_cur = child->p_limit->pl_rlimit[RLIMIT_CPU].rlim_cur;
1006 child->p_rlim_cpu.tv_sec = (rlim_cur > __INT_MAX__) ? __INT_MAX__ : rlim_cur;
1009 bzero(&child->p_stats->pstat_startzero,
1010 (unsigned) ((caddr_t)&child->p_stats->pstat_endzero -
1011 (caddr_t)&child->p_stats->pstat_startzero));
1013 bzero(&child->p_stats->user_p_prof, sizeof(struct user_uprof));
1016 (void)memcpy(child->p_sigacts,
1017 parent->p_sigacts, sizeof *child->p_sigacts);
1019 (void)memset(child->p_sigacts, 0, sizeof *child->p_sigacts);
1023 OSBitOrAtomic(P_CONTROLT, (UInt32 *)&child->p_flag);
1028 proc_signalstart(child, 0);
1029 proc_transstart(child, 0);
1032 TAILQ_INIT(&child->p_uthlist);
1033 TAILQ_INIT(&child->aio_activeq);
1034 TAILQ_INIT(&child->aio_doneq);
1036 child->p_csflags = parent->p_csflags;
1037 child->p_wqthread = parent->p_wqthread;
1038 child->p_threadstart = parent->p_threadstart;
1039 child->p_pthsize = parent->p_pthsize;
1040 workqueue_init_lock(child);
1043 child->p_lctx = NULL;
1047 enterlctx(child, parent->p_lctx, 0);
1052 return(child);