public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Torin Ford <code-monkey@qwest.net>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: 2.6.x Fork Problem?
Date: Thu, 12 Aug 2004 13:08:34 +0100	[thread overview]
Message-ID: <1092312514.21994.31.camel@localhost.localdomain> (raw)
In-Reply-To: <006101c47fff$8feedac0$0200000a@torin>

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.


  reply	other threads:[~2004-08-12 13:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-12  0:01 2.6.x Fork Problem? Torin Ford
2004-08-12 12:08 ` Alan Cox [this message]
2004-08-12 14:26 ` Jesse Pollard
2004-08-13 19:09   ` Frank van Maarseveen
2004-08-13 19:36     ` Richard B. Johnson
2004-08-13 20:06       ` Frank van Maarseveen
2004-08-13 22:50         ` Torin Ford
2004-08-13 22:07     ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1092312514.21994.31.camel@localhost.localdomain \
    --to=alan@lxorguk.ukuu.org.uk \
    --cc=code-monkey@qwest.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox