2003-01-20 21:54:35

by Andries E. Brouwer

[permalink] [raw]
Subject: [PATCH] fix setpgid

In patch-2.5.37 a return code of setpgid(pid,pgid) was broken.
If pid is not the current process and is not a child of
the current process it should return ESRCH, but the 2.5.37
patch turned this into EINVAL. The below fixes this again.

Andries

--- /linux/2.5/linux-2.5.59/linux/kernel/sys.c Tue Dec 10 18:42:42 2002
+++ /linux/2.5/linux-2.5.59a/linux/kernel/sys.c Mon Jan 20 22:04:52 2003
@@ -916,6 +916,7 @@
p = find_task_by_pid(pid);
if (!p)
goto out;
+
err = -EINVAL;
if (!thread_group_leader(p))
goto out;
@@ -927,8 +928,12 @@
err = -EACCES;
if (p->did_exec)
goto out;
- } else if (p != current)
- goto out;
+ } else {
+ err = -ESRCH;
+ if (p != current)
+ goto out;
+ }
+
err = -EPERM;
if (p->leader)
goto out;


2003-01-22 08:45:34

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH] fix setpgid


On Mon, 20 Jan 2003 [email protected] wrote:

> In patch-2.5.37 a return code of setpgid(pid,pgid) was broken. If pid is
> not the current process and is not a child of the current process it
> should return ESRCH, but the 2.5.37 patch turned this into EINVAL. The
> below fixes this again.

indeed, thanks for the fix.

Ingo