1748214 Members
3272 Online
108759 Solutions
New Discussion юеВ

signal not delivered

 
Dubost_2
Advisor

signal not delivered

I write a C program.
I set a signal handler for SIGTERM with sigaction. sigaction returns ok, everything seems fine.
A moment later, when the program is in a sleep(), I send a SIGTERM to the process. And the problem : the signal is not delivered, the process does not interrupt its sleep().
Has anyone encountered this problem. Why is my signal sometimes yes and sometimes not delivered ?
2 REPLIES 2
Peter Godron
Honored Contributor

Re: signal not delivered

Hi,
by design.

From man 3C sleep
"If a SIGALRM is generated for a multi-threaded process, it may not be delivered to a thread currently in sleep(). See sigwait(2) man page for details. In a multi-threaded process delivery of a SIGALRM to a
thread in sleep() simply causes sleep() to return without invoking the SIGALRM handler."


Dubost_2
Advisor

Re: signal not delivered

Hi,
Thank you for your answer.
This man page is not applicable.
My process is mono-threaded and I try to deliver the signal SIGTERM, not SIGALRM.