Re: 2.6.x Fork Problem?

From: Frank van Maarseveen
Date: Fri Aug 13 2004 - 14:18:06 EST


On Thu, Aug 12, 2004 at 09:26:27AM -0500, Jesse Pollard wrote:
> On Wednesday 11 August 2004 19:01, Torin Ford wrote:
> >
> > pid = fork();
> > switch (pid)
> > {
> > case -1:
> > blah; /* big trouble */
> > break;
> > case 0: /* Child */
> > exit(1);
> > break;
> > default: /* Parent */
> > pid2 = waitpid(pid, &status, 0);
> > if (pid2 == -1)
> > {
> > blah; /* check out errno */
> > }
> > }
>
> Yup - the parent process executed waitpid before the child process finished
> the setup. This can happen in a multi-cpu environment or even a single, if
> the scheduler puts the parent process higher than the child in the queue.

ugh! I can follow the rationale for SMP.

But wouldn't this kind of behavior actually break most real world programs?

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