Skip to contentSkip to conversation

sigwait in multi-threaded application

DISCUSSION KV Pavuram 1 participant 1 message Jul 19, 2005

lore
Share & tools
lore

KV Pavuram

author
#0 lore raw

Hi,

Are there any caveats of sigwait (on RT signals) in multithreaded application?

As suggested in the man page, i call

# define SIG35 35
# define SIG36 36

sigaddset (&set, SIG36) ;
pthread_sigmask (SIG_BLOCK, &set, NULL);

at the beginning of the program (in main) before I create any threads.

Then i register a signal handler for SIG35. The signal handler i call sigwait for SIG36 as

    sigaddset (&set, SIG36) ; 
    pthread_sigmask (SIG_BLOCK, &set, NULL) ;      
    sigwait (&set, &signum) ; 
    if (signum == SIG_TASKRESUME)
    {
        printf ("Task is received SIG36\n") ;
    }

Is this usage right? I see that some times if run strace on the particular thread that is currently in sigwait and then kill strace with Ctrl+C, the threads starts hogging CPU? Why should Ctrl+C wake up sigwait on SIG36??

Am I missing something? (Linux 9, 2.4 kernel)

Regards,
Pav.

__________________________________________________________
How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com