Re: setsid() semantics changed...

Daniel Roche (msmith@quix.robins.af.mil)
Sun, 14 Jul 1996 21:50:36 -0400 (EDT)


> Miquel van Smoorenburg:
>
> : Today I noticed that setsid() didn't work anymore. This is due to
> : a change in 2.0.1. I know that around that time some patches went in
> : to let Linux comform more to POSIX, so that may be the cause. This
> : is what changed:
>
> : diff -u --recursive --new-file v2.0.0/linux/kernel/sys.c linux/kernel/sys.c
> : --- v2.0.0/linux/kernel/sys.c Thu Jun 6 17:42:38 1996
> : +++ linux/kernel/sys.c Tue Jul 2 19:08:43 1996
> : @@ -634,8 +634,13 @@
> :
> : asmlinkage int sys_setsid(void)
> : {
> : - if (current->leader)
> : - return -EPERM;
> : + struct task_struct * p;
> : +
> : + for_each_task(p) {
> : + if (p->pgrp == current->pid)
> : + return -EPERM;
> : + }
> : +
>
> : Now a process that gets spawned by a shell that sets up the process group
> : for it (so it's the leader of it's own group, not session) cannot do
> : a setsid() anymore because the "if (p->pgrp == current->pid)" check will
> : match on itself.

If it is a group leader POSIX says it can't do setsid() so it doesn't
seem like checking whether p == current matters? I may be missing something.

Melvin