public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frank van Maarseveen <frankvm@xs4all.nl>
To: "Richard B. Johnson" <root@chaos.analogic.com>
Cc: Jesse Pollard <jesse@cats-chateau.net>,
	Torin Ford <code-monkey@qwest.net>,
	Linux kernel <linux-kernel@vger.kernel.org>
Subject: Re: 2.6.x Fork Problem?
Date: Fri, 13 Aug 2004 22:06:04 +0200	[thread overview]
Message-ID: <20040813200604.GA18862@janus> (raw)
In-Reply-To: <Pine.LNX.4.53.0408131521550.26183@chaos>

On Fri, Aug 13, 2004 at 03:36:34PM -0400, Richard B. Johnson wrote:
> 
> In the above code there is something missing. in the code shown,
> the child __will__ wait in exit() until somebody claims its status.
> However, the child probably did a setsid(), becoming a process-leader
> or the parent set up a SIGCHLD handler before the fork. In these
> cases, the exit() will quickly exit because somebody will claim
> the exit status.
> 
> So, by the time the parent gets the CPU, the child is long gone.
> The solution is to use the default SIGCHLD handler if the parent
> expects to get the child's status and for the child to not execute
> setsid(), which will allow init to reap its status.

AFAIK a child doing setsid() has no effect whatsoever on any wait*()
done by the parent. It just sets a new session leader.

But SIGCHLD set to SIG_IGN instead of SIG_DFL is a perfect explanation.
Rereading alan's reply I suddenly got it: "random status" didn't refer
to the &status arg but to the signal status. SIG_IGN is inherited I
guess so a

	signal(SIGCHLD, SIG_DFL);

once before the fork() should fix it. Hmm, so actually our parent should
have reset SIGCHLD before exec'ing this code. This could cause more
problems.

-- 
Frank

  reply	other threads:[~2004-08-13 20:12 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
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 [this message]
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=20040813200604.GA18862@janus \
    --to=frankvm@xs4all.nl \
    --cc=code-monkey@qwest.net \
    --cc=jesse@cats-chateau.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=root@chaos.analogic.com \
    /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