assassin5615
Programmer
I wrote a multi-thread application. in thread A, i called kill as below to send a SIGTERM signal.
kill(getpid(), SIGTERM)
in thread B, I have following code to wait for the SIGTERM signal.
sigset_t waitsignalset;
sigemptyset(&waitsignalset);
// Add whatever signal(s) to be processed by this routine
sigaddset(&waitsignalset, SIGINT);
sigaddset(&waitsignalset, SIGQUIT);
sigaddset(&waitsignalset, SIGTERM);
// Examine and Change Blocked Signals
sigprocmask(SIG_BLOCK, &waitsignalset, NULL);
result = sigwait(&waitsignalset, &sig);
I also called sigaction to register my signal handling method. however, the problem I am having is that sometimes, the sigwait can't get the SIGTERM signal, I need to let thread A to send the SIGTERM signal again to let sigwait get the signal.
Anyone might have any clue on why this happened? thanks in advance.
kill(getpid(), SIGTERM)
in thread B, I have following code to wait for the SIGTERM signal.
sigset_t waitsignalset;
sigemptyset(&waitsignalset);
// Add whatever signal(s) to be processed by this routine
sigaddset(&waitsignalset, SIGINT);
sigaddset(&waitsignalset, SIGQUIT);
sigaddset(&waitsignalset, SIGTERM);
// Examine and Change Blocked Signals
sigprocmask(SIG_BLOCK, &waitsignalset, NULL);
result = sigwait(&waitsignalset, &sig);
I also called sigaction to register my signal handling method. however, the problem I am having is that sometimes, the sigwait can't get the SIGTERM signal, I need to let thread A to send the SIGTERM signal again to let sigwait get the signal.
Anyone might have any clue on why this happened? thanks in advance.