Re: signals/threads



Ask wrote:
Hi

I have some basic questions on signals in Linux

a) In which context the signal handler is executed - (the thread that
registered for the handler, or something else)
Any of the threads that has not the signal blocked.
b) What happens if the same signal comes again while the signal handler
execution is still not complete ? Will the new signal be lost ?
Read a bit at
http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html

c)Can a deadlock possible in this case - Say thread acquires a
semaphore and is in the middle of the CS. Then signal handler comes in
execution and tries to grab the same semaphore.
Yes, there is a very limited amount of functions you can
call directly or implicittly in a signal handler, grabbing
a semaphore/mutex is not one of those.

d) In general is it advisable to use mutexes/sempahores inside signal
handlers ?
Never do it.

.



Relevant Pages

  • Re: at_exit handlers and Process.kill
    ... execution when the program exits." ... If you put "sleep 1 while true" before ... handler will never be installed. ... See signalfor descriptions and numbers of the various signals. ...
    (comp.lang.ruby)
  • Re: compile error about destructor
    ... the execution) and hence the execution hangs up. ... From MSDN, there are more values for exception code, check for the "Return ... the handler, should it skip the handler and continue ...
    (microsoft.public.vc.language)
  • Re: at_exit handlers and Process.kill
    ... execution when the program exits." ... If you put "sleep 1 while true" ... so the exit handler will never be installed. ... signals. ...
    (comp.lang.ruby)
  • Re: Trapping writes to mmapd memory.
    ... updates to the buffer _guaranteed_ to happen (assuming correct ... so that execution can be resumed as if nothing happened. ... the handler does not modify the saved state in *ctx, ...
    (comp.os.linux.development.system)
  • Re: [PATCH] ptrace(2) single-stepping into signal handlers
    ... > While being able to single-step through a ptraced process's signal ... > handler may be desirable sometimes, I would like to submit the notion ... > the next instruction in the normal stream of execution. ...
    (Linux-Kernel)