在路上
chenjifeng
全部博文(30)
2016年(2)
2010年(3)
2009年(8)
2008年(17)
bbbchina
firkraag
浪花小雨
0x1024
Clemence
des2008
44710032
zaley
skllidq
分类: LINUX
2008-11-22 21:45:39
long do_fork(unsigned long clone_flags, unsigned long stack_start, struct pt_regs *regs, unsigned long stack_size, int __user *parent_tidptr, int __user *child_tidptr) { struct task_struct *p; int trace = 0; struct pid *pid = alloc_pid();//解释1 long nr; if (!pid) return -EAGAIN; nr = pid->nr; if (unlikely(current->ptrace)) {//解释2 trace = fork_traceflag (clone_flags); if (trace) clone_flags |= CLONE_PTRACE; } p = copy_process(clone_flags, stack_start, regs, stack_size, parent_tidptr, child_tidptr, pid);//解释3 if (!IS_ERR(p)) { struct completion vfork; if (clone_flags & CLONE_VFORK) { p->vfork_done = &vfork; init_completion(&vfork); } if ((p->ptrace & PT_PTRACED) || (clone_flags & CLONE_STOPPED)) {//解释4 sigaddset(&p->pending.signal, SIGSTOP); set_tsk_thread_flag(p, TIF_SIGPENDING); } if (!(clone_flags & CLONE_STOPPED)) wake_up_new_task(p, clone_flags);//解释5 else p->state = TASK_STOPPED;//解释6 if (unlikely (trace)) {//解释7 current->ptrace_message = nr; ptrace_notify ((trace << 8) | SIGTRAP); } if (clone_flags & CLONE_VFORK) {//解释8 freezer_do_not_count(); wait_for_completion(&vfork); freezer_count(); if (unlikely (current->ptrace & PT_TRACE_VFORK_DONE)) { current->ptrace_message = nr; ptrace_notify ((PTRACE_EVENT_VFORK_DONE << 8) | SIGTRAP); } } } else { free_pid(pid); nr = PTR_ERR(p); } return nr;//解释9 }
上一篇:进程的组织
下一篇:总结与反思
登录 注册