kill signal sometimes can't be received
kill signal sometimes can't be received
(OP)
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.
RE: kill signal sometimes can't be received
Both /usr/bin/ps and /usr/ucb/ps should do so properly.
$ perl -e 'if (fork()) {sleep 20;}' &
[1] 15091
$ /usr/bin/ps -ef | grep def
root 15092 15091 0 0:00 <defunct>
$ /usr/ucb/ps ax| grep def
15092 Z 0:00 <defunct>
Bug in kernel, bug in driver, limitation in driver.