lkml.org 
[lkml]   [2008]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: sigqueue() losing signals
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..



\
 
 \ /
  Last update: 2008-10-31 01:53    [W:0.026 / U:2.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site