Skip to contentSkip to conversation

Signals and threads

DISCUSSION Robert Hancock 1 participant 1 message Nov 25, 2006 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 15 lines · shibu-kundara

Hi

I have a problem using sigaction function in pthread library. I have 2 thread each one registering

in threadA
act1.sa_handler=func1;
if(sigaction(SIGUSR1,&act1,NULL)) printf("\nSigaction failed! in th1
!!\n");

in threadB
act1.sa_handler=func2;
if(sigaction(SIGUSR1,&act2,NULL)) printf("\nSigaction failed! in th2
!!\n");

Quoted 9 lines

but when i send signal SIGUSR1 to threadA , threadA receives the signal
but the handler func2 is getting called,

Please let me know is there any way to solve this problem? thanks in advance
thomas

Signal handlers are global to the process. You can't create different handlers for the same signal in multiple threads.

Signature · 3 lines
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from [email protected]
Home Page: http://www.roberthancock.com/