[patch] Re: vfork failing - posix compliance fix

Pavel Machek (pavel@bug.ucw.cz)
Wed, 17 Mar 1999 11:37:29 +0100


Hi!

> > Pilot error. I had limit 256 of proccesses for each user, which was
> > easily exhausted by this. Kernel reports ENOMEM in such case, which is
> > I believe wrong. ENOMEM4U would be much better, EPERM seems
> > reasonable. Any comments? Do I break posix? (I'm not sending it to
> > linus. Yet.)
> >
>
> It should be EAGAIN, per POSIX 1003.1-1996 section 3.1.1.4:
>
> 3.1.1.4 Errors
>
> If any of the following conditions occur, the fork() shall return -1
> and set errno to the corresponding value:
>
> [EAGAIN] The system lacked the necessary resources to create
> another process, or the system-imposed limit on the
> total number of processes under execution by a single
> user would be exceeded.
>
> For each of the following conditions, if the condition is detected,
> the fork() shall return -1 and set errno to the corresponding value:
>
> [ENOMEM] The process requires more space than the system is
> able to supply.

It seems to me that this patch is required for correct return code
(according to posix). (It is much better idea than returning
ENOMEM, because we return ENOMEM for almost anything else.)

Pavel

--- clean/kernel/fork.c Wed Mar 10 22:37:42 1999
+++ linux/kernel/fork.c Tue Mar 16 00:03:14 1999
@@ -511,8 +533,10 @@
lock_kernel();

if (p->user) {
- if (atomic_read(&p->user->count) >= p->rlim[RLIMIT_NPROC].rlim_cur)
+ if (atomic_read(&p->user->count) >= p->rlim[RLIMIT_NPROC].rlim_cur) {
+ retval = -EAGAIN;
goto bad_fork_free;
+ }
}

{

-- 
I'm really pavel@atrey.karlin.mff.cuni.cz. 	   Pavel
Look at http://atrey.karlin.mff.cuni.cz/~pavel/ ;-).

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/