From: Edgar Toernig <froese@gmx.de>
To: Steve Beaty <beaty@emess.mscd.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: sigaction, fork, malloc, and futex
Date: Wed, 5 May 2004 02:38:52 +0200 [thread overview]
Message-ID: <20040505023852.509f5fe3.froese@gmx.de> (raw)
In-Reply-To: <200405042015.i44KFb0R001900@emess.mscd.edu>
Steve Beaty wrote:
>
>... the signal handler fork another child.
Uhh... just read that POSIX actually allows that. Evil!
I guess you're entering undiscovered land...
> void sig_handler (int signum)
> {
> int child;
>
> fprintf (stderr, "Process %d received a SIGALRM signal\n", getpid());
> if ((child = fork ()) == 0)
> {
> fprintf (stderr, "%d exiting\n", getpid());
> exit (0);
> }
> fprintf (stderr, "%d waiting for %d\n", getpid(), child);
> waitpid (child, NULL, 0);
> }
No fprintf and exit in a signal handler! Use write and _exit instead.
> if ((child = fork ()) == 0)
> {
> fprintf (stderr, "%d sending SIGALRM to %d\n", getpid(), parent);
> if (kill (parent, SIGALRM) == -1) perror ("kill 1");
> fprintf (stderr, "%d exiting\n", getpid());
> exit (0);
> }
This exit is dubious too. _exit is better.
Good luck, you may need it - ET.
next prev parent reply other threads:[~2004-05-05 0:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-04 20:15 Steve Beaty
2004-05-04 22:30 ` chris
2004-05-04 22:56 ` Zan Lynx
2004-05-04 23:16 ` Andreas Schwab
2004-05-06 21:37 ` Steve Beaty
2004-05-06 22:22 ` Zan Lynx
2004-05-06 21:36 ` Steve Beaty
2004-05-04 23:37 ` Richard B. Johnson
2004-05-06 21:41 ` Steve Beaty
2004-05-05 0:38 ` Edgar Toernig [this message]
2004-05-06 21:47 ` Steve Beaty
[not found] <1SeIE-Dy-17@gated-at.bofh.it>
[not found] ` <1ShG9-2Yt-11@gated-at.bofh.it>
2004-05-04 23:57 ` Pascal Schmidt
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=20040505023852.509f5fe3.froese@gmx.de \
--to=froese@gmx.de \
--cc=beaty@emess.mscd.edu \
--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
all inboxes | Powered by JetHome®