Re: 2.6.x Fork Problem?

From: Alan Cox
Date: Thu Aug 12 2004 - 08:13:04 EST


On Iau, 2004-08-12 at 01:01, Torin Ford wrote:
> I've widdled the code down to just do this:
>
> 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 */
> }
> }
>
> and I get the same results, so I now the exec has nothing to do with it.

Well I see two oddities in the example. You call exit() not _exit() so
the child will duplicate various queued stdio of the parent. Doesn't
seem to be relevant however.

Secondly and I suspect of importance you don't do anything with SIGCLD
so you are inheriting a random status. If the child signal is being
ignored then it will be cleared automatically. In that situation your
code functionality depends solely upon which thread runs first.

-
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/