diff options
Diffstat (limited to 'kernel/sys.c')
-rw-r--r-- | kernel/sys.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index 43e557211d8d..f497bf56ada1 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -1215,24 +1215,22 @@ asmlinkage long sys_getsid(pid_t pid) | |||
1215 | 1215 | ||
1216 | asmlinkage long sys_setsid(void) | 1216 | asmlinkage long sys_setsid(void) |
1217 | { | 1217 | { |
1218 | struct task_struct *group_leader = current->group_leader; | ||
1218 | struct pid *pid; | 1219 | struct pid *pid; |
1219 | int err = -EPERM; | 1220 | int err = -EPERM; |
1220 | 1221 | ||
1221 | if (!thread_group_leader(current)) | ||
1222 | return -EINVAL; | ||
1223 | |||
1224 | down(&tty_sem); | 1222 | down(&tty_sem); |
1225 | write_lock_irq(&tasklist_lock); | 1223 | write_lock_irq(&tasklist_lock); |
1226 | 1224 | ||
1227 | pid = find_pid(PIDTYPE_PGID, current->pid); | 1225 | pid = find_pid(PIDTYPE_PGID, group_leader->pid); |
1228 | if (pid) | 1226 | if (pid) |
1229 | goto out; | 1227 | goto out; |
1230 | 1228 | ||
1231 | current->signal->leader = 1; | 1229 | group_leader->signal->leader = 1; |
1232 | __set_special_pids(current->pid, current->pid); | 1230 | __set_special_pids(group_leader->pid, group_leader->pid); |
1233 | current->signal->tty = NULL; | 1231 | group_leader->signal->tty = NULL; |
1234 | current->signal->tty_old_pgrp = 0; | 1232 | group_leader->signal->tty_old_pgrp = 0; |
1235 | err = process_group(current); | 1233 | err = process_group(group_leader); |
1236 | out: | 1234 | out: |
1237 | write_unlock_irq(&tasklist_lock); | 1235 | write_unlock_irq(&tasklist_lock); |
1238 | up(&tty_sem); | 1236 | up(&tty_sem); |