Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

kill signal sometimes can't be received

Status
Not open for further replies.

assassin5615

Programmer
Nov 8, 2010
1
0
0
CN
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.
 
I'm unaware of any recent version of 'ps' failing to identify zombies.
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.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top