Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 24545
b: refs/heads/master
c: d73d652
h: refs/heads/master
i:
  24543: e7ac259
v: v3
  • Loading branch information
Eric W. Biederman authored and Linus Torvalds committed Mar 29, 2006
1 parent e5779bf commit 25f88df
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 35 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 652486fb84a07ed750f1c11639518f55808bf555
refs/heads/master: d73d65293e3e2de7e916a89c8da30be0948afab7
14 changes: 11 additions & 3 deletions trunk/fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,17 @@ static int de_thread(struct task_struct *tsk)
remove_parent(current);
remove_parent(leader);

switch_exec_pids(leader, current);

/* Become a process group leader with the old leader's pid.
* Note: The old leader also uses thispid until release_task
* is called. Odd but simple and correct.
*/
detach_pid(current, PIDTYPE_PID);
current->pid = leader->pid;
attach_pid(current, PIDTYPE_PID, current->pid);
attach_pid(current, PIDTYPE_PGID, current->signal->pgrp);
attach_pid(current, PIDTYPE_SID, current->signal->session);
list_add_tail(&current->tasks, &init_task.tasks);

current->parent = current->real_parent = leader->real_parent;
leader->parent = leader->real_parent = child_reaper;
Expand All @@ -722,8 +732,6 @@ static int de_thread(struct task_struct *tsk)
__ptrace_link(current, parent);
}

list_del(&current->tasks);
list_add_tail(&current->tasks, &init_task.tasks);
current->exit_signal = SIGCHLD;

BUG_ON(leader->exit_state != EXIT_ZOMBIE);
Expand Down
1 change: 0 additions & 1 deletion trunk/include/linux/pid.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ extern struct pid *FASTCALL(find_pid(enum pid_type, int));

extern int alloc_pidmap(void);
extern void FASTCALL(free_pidmap(int));
extern void switch_exec_pids(struct task_struct *leader, struct task_struct *thread);

#define do_each_task_pid(who, type, task) \
if ((task = find_task_by_pid_type(type, who))) { \
Expand Down
30 changes: 0 additions & 30 deletions trunk/kernel/pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,36 +217,6 @@ task_t *find_task_by_pid_type(int type, int nr)

EXPORT_SYMBOL(find_task_by_pid_type);

/*
* This function switches the PIDs if a non-leader thread calls
* sys_execve() - this must be done without releasing the PID.
* (which a detach_pid() would eventually do.)
*/
void switch_exec_pids(task_t *leader, task_t *thread)
{
__detach_pid(leader, PIDTYPE_PID);
__detach_pid(leader, PIDTYPE_TGID);
__detach_pid(leader, PIDTYPE_PGID);
__detach_pid(leader, PIDTYPE_SID);

__detach_pid(thread, PIDTYPE_PID);
__detach_pid(thread, PIDTYPE_TGID);

leader->pid = leader->tgid = thread->pid;
thread->pid = thread->tgid;

attach_pid(thread, PIDTYPE_PID, thread->pid);
attach_pid(thread, PIDTYPE_TGID, thread->tgid);
attach_pid(thread, PIDTYPE_PGID, thread->signal->pgrp);
attach_pid(thread, PIDTYPE_SID, thread->signal->session);
list_add_tail(&thread->tasks, &init_task.tasks);

attach_pid(leader, PIDTYPE_PID, leader->pid);
attach_pid(leader, PIDTYPE_TGID, leader->tgid);
attach_pid(leader, PIDTYPE_PGID, leader->signal->pgrp);
attach_pid(leader, PIDTYPE_SID, leader->signal->session);
}

/*
* The pid hash table is scaled according to the amount of memory in the
* machine. From a minimum of 16 slots up to 4096 slots at one gigabyte or
Expand Down

0 comments on commit 25f88df

Please sign in to comment.