From: Scott James Remnant <scott@netsplit.com>
To: Davide Libenzi <davidel@xmailserver.org>
Cc: Casey Dahlin <cdahlin@redhat.com>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH] waitfd: file descriptor to wait on child processes
Date: Fri, 12 Dec 2008 15:28:11 -0800 [thread overview]
Message-ID: <1229124491.12618.5.camel@warcraft> (raw)
In-Reply-To: <alpine.DEB.1.10.0812091127160.17144@alien.or.mcafeemobile.com>
[-- Attachment #1: Type: text/plain, Size: 1790 bytes --]
On Tue, 2008-12-09 at 11:41 -0800, Davide Libenzi wrote:
> On Tue, 9 Dec 2008, Casey Dahlin wrote:
>
> > Linux already has signalfd, timerfd, and eventfd to expose signals, timers,
> > and events via a file descriptor. This patch is a working prototype for a
> > fourth: waitfd. It pretty much does what the name suggests: reading from it
> > yields a series of status ints (as would be written into the second argument
> > of waitpid) for child processes that have changed state. It takes essentially
> > the same arguments as waitpid (for now) and supports the same set of features.
> >
> What's wrong in having a signalfd on SIGCHLD, than doing waitpid() once
> you get the signal?
>
Because SIGCHLD isn't a POSIX realtime signal, only one copy of it will
be queued at any one time -- even with signalfd(), and even though they
have different (useful) siginfo_t.
So if you have three children die in rapid succession, you only get the
siginfo for the first one. Thus you still have to call
waitid()/waitpid() in a loop, and wait on everything.
Could the fact that you don't get signalfd notification of the
additional signals be considered a bug? Or possibly a useful additional
feature?
If we were able to read all the queued SIGCHLD signals with signalfd
(preserving the one pending only behaviour of ordinary delivery), then a
loop like the following would be possible:
sigemptyset (&mask);
sigaddset (&mask, SIGCHLD);
sfd = signalfd (-1, &mask, 0);
for (;;) {
read (sfd, &fdsi, sizeof (struct signalfd_siginfo));
waitpid (fdsi.ssi_pid, 0, 0);
}
So you only need to wait for each one individually.
Scott
--
Have you ever, ever felt like this?
Had strange things happen? Are you going round the twist?
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2008-12-13 2:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-09 17:00 [RFC PATCH] waitfd: file descriptor to wait on child processes Casey Dahlin
2008-12-09 17:05 ` Alan Cox
2008-12-09 17:12 ` Scott James Remnant
2008-12-09 18:46 ` Casey Dahlin
2008-12-09 19:04 ` Alan Cox
2008-12-09 19:21 ` Casey Dahlin
2008-12-09 19:41 ` Davide Libenzi
2008-12-09 20:09 ` Casey Dahlin
2008-12-12 23:28 ` Scott James Remnant [this message]
2008-12-13 4:29 ` Davide Libenzi
2008-12-13 8:43 ` Scott James Remnant
2008-12-13 18:39 ` Davide Libenzi
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=1229124491.12618.5.camel@warcraft \
--to=scott@netsplit.com \
--cc=cdahlin@redhat.com \
--cc=davidel@xmailserver.org \
--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