summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@home.osdl.org>2003-10-09 01:13:56 -0700
committerLinus Torvalds <torvalds@home.osdl.org>2003-10-09 01:13:56 -0700
commit06349d9d2b7f57ebce92b2838a55722934e394f6 (patch)
treeec8020b2672cea8a8ff194f6a345ae1724baec4e /kernel
parent6601345fc15e63c7972db7118df6e033678977f7 (diff)
Revert the process group accessor functions. They are buggy, and
cause NULL pointer references in /proc. Moreover, it's questionable whether the whole thing makes sense at all. Per-thread state is good. Cset exclude: davem@nuts.ninka.net|ChangeSet|20031005193942|01097 Cset exclude: akpm@osdl.org[torvalds]|ChangeSet|20031005180420|42200 Cset exclude: akpm@osdl.org[torvalds]|ChangeSet|20031005180411|42211
Diffstat (limited to 'kernel')
-rw-r--r--kernel/acct.c2
-rw-r--r--kernel/exit.c22
-rw-r--r--kernel/fork.c14
-rw-r--r--kernel/pid.c8
-rw-r--r--kernel/signal.c5
-rw-r--r--kernel/sys.c18
6 files changed, 31 insertions, 38 deletions
diff --git a/kernel/acct.c b/kernel/acct.c
index 37e98d713023..a679f4bb9854 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -343,7 +343,7 @@ static void do_acct_process(long exitcode, struct file *file)
/* we really need to bite the bullet and change layout */
ac.ac_uid = current->uid;
ac.ac_gid = current->gid;
- ac.ac_tty = process_tty(current) ? old_encode_dev(tty_devnum(process_tty(current))) : 0;
+ ac.ac_tty = current->tty ? old_encode_dev(tty_devnum(current->tty)) : 0;
ac.ac_flag = 0;
if (current->flags & PF_FORKNOEXEC)
diff --git a/kernel/exit.c b/kernel/exit.c
index d7ed79d9a144..08e2068e2ae5 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -119,13 +119,13 @@ int session_of_pgrp(int pgrp)
read_lock(&tasklist_lock);
for_each_task_pid(pgrp, PIDTYPE_PGID, p, l, pid)
- if (process_session(p) > 0) {
- sid = process_session(p);
+ if (p->session > 0) {
+ sid = p->session;
goto out;
}
p = find_task_by_pid(pgrp);
if (p)
- sid = process_session(p);
+ sid = p->session;
out:
read_unlock(&tasklist_lock);
@@ -153,7 +153,7 @@ static int will_become_orphaned_pgrp(int pgrp, task_t *ignored_task)
|| p->real_parent->pid == 1)
continue;
if (process_group(p->real_parent) != pgrp
- && process_session(p->real_parent) == process_session(p)) {
+ && p->real_parent->session == p->session) {
ret = 0;
break;
}
@@ -242,14 +242,14 @@ void __set_special_pids(pid_t session, pid_t pgrp)
{
struct task_struct *curr = current;
- if (process_session(curr) != session) {
+ if (curr->session != session) {
detach_pid(curr, PIDTYPE_SID);
- curr->signal->session = session;
+ curr->session = session;
attach_pid(curr, PIDTYPE_SID, session);
}
if (process_group(curr) != pgrp) {
detach_pid(curr, PIDTYPE_PGID);
- curr->signal->pgrp = pgrp;
+ curr->group_leader->__pgrp = pgrp;
attach_pid(curr, PIDTYPE_PGID, pgrp);
}
}
@@ -303,7 +303,7 @@ void daemonize(const char *name, ...)
exit_mm(current);
set_special_pids(1, 1);
- current->signal->tty = NULL;
+ current->tty = NULL;
/* Block and flush all signals */
sigfillset(&blocked);
@@ -515,7 +515,7 @@ static inline void reparent_thread(task_t *p, task_t *father, int traced)
* outside, so the child pgrp is now orphaned.
*/
if ((process_group(p) != process_group(father)) &&
- (process_session(p) == process_session(father))) {
+ (p->session == father->session)) {
int pgrp = process_group(p);
if (will_become_orphaned_pgrp(pgrp, NULL) && has_stopped_jobs(pgrp)) {
@@ -625,7 +625,7 @@ static void exit_notify(struct task_struct *tsk)
t = tsk->real_parent;
if ((process_group(t) != process_group(tsk)) &&
- (process_session(t) == process_session(tsk)) &&
+ (t->session == tsk->session) &&
will_become_orphaned_pgrp(process_group(tsk), tsk) &&
has_stopped_jobs(process_group(tsk))) {
__kill_pg_info(SIGHUP, (void *)1, process_group(tsk));
@@ -720,7 +720,7 @@ NORET_TYPE void do_exit(long code)
exit_itimers(tsk);
exit_thread();
- if (process_session_leader(tsk))
+ if (tsk->leader)
disassociate_ctty(1);
module_put(tsk->thread_info->exec_domain->module);
diff --git a/kernel/fork.c b/kernel/fork.c
index 0afba3e0e0ac..1834f99dd054 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -743,12 +743,6 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
sig->curr_target = NULL;
init_sigpending(&sig->shared_pending);
- sig->tty = process_tty(current);
- sig->pgrp = process_group(current);
- sig->session = process_session(current);
- sig->leader = 0; /* session leadership doesn't inherit */
- sig->tty_old_pgrp = 0;
-
return 0;
}
@@ -795,9 +789,7 @@ struct task_struct *copy_process(unsigned long clone_flags,
* Thread groups must share signals as well, and detached threads
* can only be started up within the thread group.
*/
- if ((clone_flags & CLONE_THREAD) &&
- (clone_flags & (CLONE_SIGHAND|CLONE_DETACHED)) !=
- (CLONE_SIGHAND|CLONE_DETACHED))
+ if ((clone_flags & CLONE_THREAD) && !(clone_flags & CLONE_SIGHAND))
return ERR_PTR(-EINVAL);
/*
@@ -902,6 +894,8 @@ struct task_struct *copy_process(unsigned long clone_flags,
init_timer(&p->real_timer);
p->real_timer.data = (unsigned long) p;
+ p->leader = 0; /* session leadership doesn't inherit */
+ p->tty_old_pgrp = 0;
p->utime = p->stime = 0;
p->cutime = p->cstime = 0;
p->array = NULL;
@@ -1046,7 +1040,7 @@ struct task_struct *copy_process(unsigned long clone_flags,
if (thread_group_leader(p)) {
attach_pid(p, PIDTYPE_TGID, p->tgid);
attach_pid(p, PIDTYPE_PGID, process_group(p));
- attach_pid(p, PIDTYPE_SID, process_session(p));
+ attach_pid(p, PIDTYPE_SID, p->session);
if (p->pid)
__get_cpu_var(process_counts)++;
} else
diff --git a/kernel/pid.c b/kernel/pid.c
index 624b54602fcb..4bb0bc0159d4 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -253,14 +253,14 @@ void switch_exec_pids(task_t *leader, task_t *thread)
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);
+ attach_pid(thread, PIDTYPE_PGID, leader->__pgrp);
+ attach_pid(thread, PIDTYPE_SID, thread->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);
+ attach_pid(leader, PIDTYPE_PGID, leader->__pgrp);
+ attach_pid(leader, PIDTYPE_SID, leader->session);
}
/*
diff --git a/kernel/signal.c b/kernel/signal.c
index 469deaeeff56..852da1a009da 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -593,8 +593,7 @@ static int check_kill_permission(int sig, struct siginfo *info,
error = -EPERM;
if ((!info || ((unsigned long)info != 1 &&
(unsigned long)info != 2 && SI_FROMUSER(info)))
- && ((sig != SIGCONT) ||
- (process_session(current) != process_session(t)))
+ && ((sig != SIGCONT) || (current->session != t->session))
&& (current->euid ^ t->suid) && (current->euid ^ t->uid)
&& (current->uid ^ t->suid) && (current->uid ^ t->uid)
&& !capable(CAP_KILL))
@@ -1103,7 +1102,7 @@ kill_sl_info(int sig, struct siginfo *info, pid_t sid)
retval = -ESRCH;
read_lock(&tasklist_lock);
for_each_task_pid(sid, PIDTYPE_SID, p, l, pid) {
- if (!process_session_leader(p))
+ if (!p->leader)
continue;
err = group_send_sig_info(sig, info, p);
if (retval)
diff --git a/kernel/sys.c b/kernel/sys.c
index 7413a1067472..9b914004fde8 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -969,7 +969,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
if (p->parent == current || p->real_parent == current) {
err = -EPERM;
- if (process_session(p) != process_session(current))
+ if (p->session != current->session)
goto out;
err = -EACCES;
if (p->did_exec)
@@ -981,7 +981,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
}
err = -EPERM;
- if (process_session_leader(p))
+ if (p->leader)
goto out;
if (pgid != pid) {
@@ -990,7 +990,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
struct list_head *l;
for_each_task_pid(pgid, PIDTYPE_PGID, p, l, pid)
- if (process_session(p) == process_session(current))
+ if (p->session == current->session)
goto ok_pgid;
goto out;
}
@@ -1002,7 +1002,7 @@ ok_pgid:
if (process_group(p) != pgid) {
detach_pid(p, PIDTYPE_PGID);
- p->signal->pgrp = pgid;
+ p->group_leader->__pgrp = pgid;
attach_pid(p, PIDTYPE_PGID, pgid);
}
@@ -1044,7 +1044,7 @@ asmlinkage long sys_getpgrp(void)
asmlinkage long sys_getsid(pid_t pid)
{
if (!pid) {
- return process_session(current);
+ return current->session;
} else {
int retval;
struct task_struct *p;
@@ -1056,7 +1056,7 @@ asmlinkage long sys_getsid(pid_t pid)
if(p) {
retval = security_task_getsid(p);
if (!retval)
- retval = process_session(p);
+ retval = p->session;
}
read_unlock(&tasklist_lock);
return retval;
@@ -1077,10 +1077,10 @@ asmlinkage long sys_setsid(void)
if (pid)
goto out;
- current->signal->leader = 1;
+ current->leader = 1;
__set_special_pids(current->pid, current->pid);
- current->signal->tty = NULL;
- current->signal->tty_old_pgrp = 0;
+ current->tty = NULL;
+ current->tty_old_pgrp = 0;
err = process_group(current);
out:
write_unlock_irq(&tasklist_lock);