aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 417cb864e20c..7d6962fb6156 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1121,6 +1121,12 @@ static void posix_cpu_timers_init(struct task_struct *tsk)
1121 INIT_LIST_HEAD(&tsk->cpu_timers[2]); 1121 INIT_LIST_HEAD(&tsk->cpu_timers[2]);
1122} 1122}
1123 1123
1124static inline void
1125init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
1126{
1127 task->pids[type].pid = pid;
1128}
1129
1124/* 1130/*
1125 * This creates a new process as a copy of the old one, 1131 * This creates a new process as a copy of the old one,
1126 * but does not actually start it yet. 1132 * but does not actually start it yet.
@@ -1449,7 +1455,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1449 if (likely(p->pid)) { 1455 if (likely(p->pid)) {
1450 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace); 1456 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
1451 1457
1458 init_task_pid(p, PIDTYPE_PID, pid);
1452 if (thread_group_leader(p)) { 1459 if (thread_group_leader(p)) {
1460 init_task_pid(p, PIDTYPE_PGID, task_pgrp(current));
1461 init_task_pid(p, PIDTYPE_SID, task_session(current));
1462
1453 if (is_child_reaper(pid)) { 1463 if (is_child_reaper(pid)) {
1454 ns_of_pid(pid)->child_reaper = p; 1464 ns_of_pid(pid)->child_reaper = p;
1455 p->signal->flags |= SIGNAL_UNKILLABLE; 1465 p->signal->flags |= SIGNAL_UNKILLABLE;
@@ -1457,10 +1467,10 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1457 1467
1458 p->signal->leader_pid = pid; 1468 p->signal->leader_pid = pid;
1459 p->signal->tty = tty_kref_get(current->signal->tty); 1469 p->signal->tty = tty_kref_get(current->signal->tty);
1460 attach_pid(p, PIDTYPE_PGID, task_pgrp(current));
1461 attach_pid(p, PIDTYPE_SID, task_session(current));
1462 list_add_tail(&p->sibling, &p->real_parent->children); 1470 list_add_tail(&p->sibling, &p->real_parent->children);
1463 list_add_tail_rcu(&p->tasks, &init_task.tasks); 1471 list_add_tail_rcu(&p->tasks, &init_task.tasks);
1472 attach_pid(p, PIDTYPE_PGID);
1473 attach_pid(p, PIDTYPE_SID);
1464 __this_cpu_inc(process_counts); 1474 __this_cpu_inc(process_counts);
1465 } else { 1475 } else {
1466 current->signal->nr_threads++; 1476 current->signal->nr_threads++;
@@ -1470,7 +1480,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1470 list_add_tail_rcu(&p->thread_group, 1480 list_add_tail_rcu(&p->thread_group,
1471 &p->group_leader->thread_group); 1481 &p->group_leader->thread_group);
1472 } 1482 }
1473 attach_pid(p, PIDTYPE_PID, pid); 1483 attach_pid(p, PIDTYPE_PID);
1474 nr_threads++; 1484 nr_threads++;
1475 } 1485 }
1476 1486