23,107
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
int main()
{
while(1)
{
sleep(3);
}
return 0;
}
static struct task_struct *copy_process(unsigned long clone_flags,
unsigned long stack_start,
unsigned long stack_size,
int __user *child_tidptr,
struct pid *pid,
int trace)
{
……
if (likely(p->pid)) {
ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
init_task_pid(p, PIDTYPE_PID, pid);
if (thread_group_leader(p)) {
init_task_pid(p, PIDTYPE_PGID, task_pgrp(current));//把当前进程的pid设置子进程的pgid
……
}是吗
[/quote]
非常感谢你的回复!才看到回复实在抱歉,还是有点不太明白你的意思:
一: bash是调用了setpgid了是吗?[/quote]
对,是的。你可以下载bash的最新代码看一下,在这个函数里make_child有调用setpgid。
static struct task_struct *copy_process(unsigned long clone_flags,
unsigned long stack_start,
unsigned long stack_size,
int __user *child_tidptr,
struct pid *pid,
int trace)
{
……
if (likely(p->pid)) {
ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
init_task_pid(p, PIDTYPE_PID, pid);
if (thread_group_leader(p)) {
init_task_pid(p, PIDTYPE_PGID, task_pgrp(current));//把当前进程的pid设置子进程的pgid
……
}是吗
[/quote]
非常感谢你的回复!才看到回复实在抱歉,还是有点不太明白你的意思:
一: bash是调用了setpgid了是吗?
static struct task_struct *copy_process(unsigned long clone_flags,
unsigned long stack_start,
unsigned long stack_size,
int __user *child_tidptr,
struct pid *pid,
int trace)
{
……
if (likely(p->pid)) {
ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
init_task_pid(p, PIDTYPE_PID, pid);
if (thread_group_leader(p)) {
init_task_pid(p, PIDTYPE_PGID, task_pgrp(current));//把当前进程的pid设置子进程的pgid
……
}