public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Hancock <hancockr@shaw.ca>
To: James Renton <jrenton@castel.com>
Cc: linux-kernel@vger.kernel.org, Joe Maldonado <jmaldonado@castel.com>
Subject: Re: sigqueue() losing signals
Date: Thu, 30 Oct 2008 18:51:36 -0600	[thread overview]
Message-ID: <490A5698.4080302@shaw.ca> (raw)
In-Reply-To: <fa.mqI1CnLbqkcTn2yfwoMcj8Ca54c@ifi.uio.no>

James Renton wrote:
> I needed to kick off a bunch of background threads and receive
> notification if one failed due to fatal error.  I was hoping waitpid()
> would work; but found out quickly that although each thread has a pid_t;
> threads and processes were not interchangeable.  Without a timed
> pthread_join() over multiple threads (like WIN32
> WaitForMultipleObjects), I formulated a seemingly dead simple
> implementation using signals.  I hacked out a quick prototype to ensure
> I could get the signals to work as desired.  
> 
> When I ran the prototype, I experienced behavior looking very bug-like;
> but I wanted to post it here in case I am misunderstanding unix signals
> and just doing something silly.  I am requesting for comments or
> [hopefully clever] suggestions... Code follows:

For normal signals, you're not guaranteed that the signal handler will 
be called once for every time the signal is raised. You may get only one 
signal handler call for multiple events if they happen in rapid 
succession. Maybe if you use realtime signals it will work. But this 
seems like a bizarre way to accomplish the task.. better to just set 
some pthread condition in your threads when they exit and do a 
pthread_cond_timedwait on that condition in the main thread.

IMHO, in general, when signals are the answer, chances are the question 
is wrong..


       reply	other threads:[~2008-10-31  0:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fa.mqI1CnLbqkcTn2yfwoMcj8Ca54c@ifi.uio.no>
2008-10-31  0:51 ` Robert Hancock [this message]
2008-10-30 22:12 sigqueue() losing signals James Renton
2008-10-30 22:58 ` Samuel Thibault

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=490A5698.4080302@shaw.ca \
    --to=hancockr@shaw.ca \
    --cc=jmaldonado@castel.com \
    --cc=jrenton@castel.com \
    --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