Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 24925
b: refs/heads/master
c: 390e2ff
h: refs/heads/master
i:
  24923: 392a0aa
v: v3
  • Loading branch information
Eric W. Biederman authored and Linus Torvalds committed Mar 31, 2006
1 parent 2eb2351 commit ce09e10
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 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: 9741ef964dc8bfeb6520825df9fed8f538c3336e
refs/heads/master: 390e2ff07712468ce6600a43aa91e897b056ce12
19 changes: 15 additions & 4 deletions trunk/kernel/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -1372,18 +1372,29 @@ asmlinkage long sys_getsid(pid_t pid)
asmlinkage long sys_setsid(void)
{
struct task_struct *group_leader = current->group_leader;
struct pid *pid;
pid_t session;
int err = -EPERM;

mutex_lock(&tty_mutex);
write_lock_irq(&tasklist_lock);

pid = find_pid(PIDTYPE_PGID, group_leader->pid);
if (pid)
/* Fail if I am already a session leader */
if (group_leader->signal->leader)
goto out;

session = group_leader->pid;
/* Fail if a process group id already exists that equals the
* proposed session id.
*
* Don't check if session id == 1 because kernel threads use this
* session id and so the check will always fail and make it so
* init cannot successfully call setsid.
*/
if (session > 1 && find_task_by_pid_type(PIDTYPE_PGID, session))
goto out;

group_leader->signal->leader = 1;
__set_special_pids(group_leader->pid, group_leader->pid);
__set_special_pids(session, session);
group_leader->signal->tty = NULL;
group_leader->signal->tty_old_pgrp = 0;
err = process_group(group_leader);
Expand Down

0 comments on commit ce09e10

Please sign in to comment.