mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 17:41:50 +00:00
[PATCH] setpgid: should work for sub-threads
setsid() does not work unless the calling process is a thread_group_leader(). 'man setpgid' does not tell anything about that, so I consider this behaviour is a bug. Signed-off-by: Oren Laadan <orenl@cs.columbia.edu> Cc: Oleg Nesterov <oleg@tv-sign.ru> Cc: Roland McGrath <roland@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
ee0acf90d3
commit
e19f247a3d
2 changed files with 8 additions and 10 deletions
|
@ -257,7 +257,7 @@ static inline void reparent_to_init(void)
|
||||||
|
|
||||||
void __set_special_pids(pid_t session, pid_t pgrp)
|
void __set_special_pids(pid_t session, pid_t pgrp)
|
||||||
{
|
{
|
||||||
struct task_struct *curr = current;
|
struct task_struct *curr = current->group_leader;
|
||||||
|
|
||||||
if (curr->signal->session != session) {
|
if (curr->signal->session != session) {
|
||||||
detach_pid(curr, PIDTYPE_SID);
|
detach_pid(curr, PIDTYPE_SID);
|
||||||
|
|
16
kernel/sys.c
16
kernel/sys.c
|
@ -1215,24 +1215,22 @@ asmlinkage long sys_getsid(pid_t pid)
|
||||||
|
|
||||||
asmlinkage long sys_setsid(void)
|
asmlinkage long sys_setsid(void)
|
||||||
{
|
{
|
||||||
|
struct task_struct *group_leader = current->group_leader;
|
||||||
struct pid *pid;
|
struct pid *pid;
|
||||||
int err = -EPERM;
|
int err = -EPERM;
|
||||||
|
|
||||||
if (!thread_group_leader(current))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
down(&tty_sem);
|
down(&tty_sem);
|
||||||
write_lock_irq(&tasklist_lock);
|
write_lock_irq(&tasklist_lock);
|
||||||
|
|
||||||
pid = find_pid(PIDTYPE_PGID, current->pid);
|
pid = find_pid(PIDTYPE_PGID, group_leader->pid);
|
||||||
if (pid)
|
if (pid)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
current->signal->leader = 1;
|
group_leader->signal->leader = 1;
|
||||||
__set_special_pids(current->pid, current->pid);
|
__set_special_pids(group_leader->pid, group_leader->pid);
|
||||||
current->signal->tty = NULL;
|
group_leader->signal->tty = NULL;
|
||||||
current->signal->tty_old_pgrp = 0;
|
group_leader->signal->tty_old_pgrp = 0;
|
||||||
err = process_group(current);
|
err = process_group(group_leader);
|
||||||
out:
|
out:
|
||||||
write_unlock_irq(&tasklist_lock);
|
write_unlock_irq(&tasklist_lock);
|
||||||
up(&tty_sem);
|
up(&tty_sem);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue