longjump && re-entrancy



I understand (which is to say I believe it is the case)
that it is safe to call longjump() from a signal handler.
I also understand that non-reentrant functions are unsafe
to call from a signal handler. But it seems to me that
if the program ever calls a non-rentrant function and
longjumps out of a signal handler, then all the issues of
non-reentrancy apply. eg:

setjumpbuf
fprintf() <-- interrupted
[in handler]:
longjump

Could hang if printf still has a lock on the FILE *.

Or does the stack unwinding from longjump magically
release the locks?
.



Relevant Pages

  • Re: longjmp vs goto
    ... and then I would get into my signal handler and call longjump ... But since the signal handler is the only place where I call ... Operating system detects this and goes into "exception handling" ...
    (comp.lang.c)
  • Re: longjmp vs goto
    ... >>longjmp in the buserror signal handler. ... > longjmp in a signal handler invokes ... But doesn't that mean that each function doesn't have to be reentrant? ... So what I understand is that if I was busy calling longjump from my ...
    (comp.lang.c)
  • Re: Catching SIGSEGV with signal() in 2.6
    ... Are you using a longjump to get out of the signal handler? ... You may find that you can trap SIGSEGV, ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Can fork be used in a signal handler?
    ... So i want to use fork inside the signal handler for SIGCHLD. ... I know that non-reentrant functions can not be ...
    (comp.unix.programmer)