进程fork处理
来源:互联网 发布:沃尔玛的物流网络 编辑:程序博客网 时间:2024/05/28 01:34
进程或者线程创建do_fork
/* For compatibility with architectures that call do_fork directly rather than * using the syscall entry points below. */long do_fork(unsigned long clone_flags, unsigned long stack_start, unsigned long stack_size, int __user *parent_tidptr, int __user *child_tidptr){ return _do_fork(clone_flags, stack_start, stack_size, parent_tidptr, child_tidptr, 0);}
/* * Ok, this is the main fork-routine. * * It copies the process, and if successful kick-starts * it and waits for it to finish using the VM if required. */long _do_fork(unsigned long clone_flags, unsigned long stack_start, unsigned long stack_size, int __user *parent_tidptr, int __user *child_tidptr, unsigned long tls){ struct task_struct *p; int trace = 0; long nr;
/* * Determine whether and which event to report to ptracer. When * called from kernel_thread or CLONE_UNTRACED is explicitly * requested, no event is reported; otherwise, report if the event * for the type of forking is enabled. */ if (!(clone_flags & CLONE_UNTRACED)) { if (clone_flags & CLONE_VFORK) trace = PTRACE_EVENT_VFORK; else if ((clone_flags & CSIGNAL) != SIGCHLD) trace = PTRACE_EVENT_CLONE; else trace = PTRACE_EVENT_FORK;
if (likely(!ptrace_event_enabled(current, trace))) trace = 0; }
p = copy_process(clone_flags, stack_start, stack_size, child_tidptr, NULL, trace, tls, NUMA_NO_NODE); add_latent_entropy(); /* * Do this prior waking up the new thread - the thread pointer * might get invalid after that point, if the thread exits quickly. */ if (!IS_ERR(p)) { struct completion vfork; struct pid *pid;
trace_sched_process_fork(current, p);
pid = get_task_pid(p, PIDTYPE_PID); nr = pid_vnr(pid);
if (clone_flags & CLONE_PARENT_SETTID) put_user(nr, parent_tidptr);
if (clone_flags & CLONE_VFORK) { p->vfork_done = &vfork; init_completion(&vfork); get_task_struct(p); }
wake_up_new_task(p);
/* forking complete and child started to run, tell ptracer */ if (unlikely(trace)) ptrace_event_pid(trace, pid);
if (clone_flags & CLONE_VFORK) { if (!wait_for_vfork_done(p, &vfork)) ptrace_event_pid(PTRACE_EVENT_VFORK_DONE, pid); }
put_pid(pid); } else { nr = PTR_ERR(p); } return nr;}
- 进程fork处理
- fork进程的一些处理,
- 进程fork
- 进程fork
- 进程fork();
- fork进程
- perl fork 后出现僵尸进程的处理
- fork 和 exec 对子进程继承父进程处理信号处理函数的影响
- fork-fork总共几个进程
- fork exec对子进程继承父进程信号处理机制的影响--APUE
- fork - 子进程在复制父进程的信号处理方式
- fork exec对子进程继承父进程信号处理机制的影响--APUE
- fork exec对子进程继承父进程信号处理机制的影响--APUE
- fork() 进程学习
- 创建进程fork
- 多进程总结-fork
- 创建进程库函数fork
- fork() 创建新进程
- Android 在服务Service中创建Dialog对话框
- 判断两个string是否相等
- 第七次c++实验 愚蠢的富人
- switch语句
- 大型网站技术架构-4 瞬时响应:网站的高性能架构
- 进程fork处理
- poj 2420 A Star not a Tree?(模拟退火求费马点)
- iOS 10和macOS中的卷积神经网络
- ZooKeeper数据模型
- c# 导出excel 填充数据 输出到浏览器
- 程序设计入门week3:数字特征值(c中如何使用次方)
- input输入控件的新类型
- Oauth和Oauth2.0的区别
- 去掉FreeMind的红色波浪线,关闭拼写检查