pitfalls of signals

From: Mantorok Redgormor (nethlek_at_tokyo.com)
Date: 10/31/03


Date: 31 Oct 2003 03:36:32 -0800

Should I just avoid them?
I have heard many bad things about them
1) if you set a signal handler, you can't really ignore the signal and
continue with normal program execution, because after that undefined
behavior is invoked.

2) if you have a signal handler set for say SIG_INT and you continue
to reset the handler after you received the signal, to continue normal
program execution, and the signal is received twice or something you
end up invoking undefined behavior and re-entry of a signal handler
function causing major problems

what are some other things i should be aware of for signals?

and what should i do about points 1 and 2?

there really is no alternative to a portable function like signal but
signal itself seems to be a hazardous piece of crap



Relevant Pages

  • Re: memmove crash
    ... arrays pointed to by the two pointers, and compare the number of characters to be moved with those sizes. ... all kinds of stuff that has to be done when that signal handler is called, so I'd have to go through it all and make sure none of it calls any libc functions that are going to do a malloc, and it's not like it's easy to tell which ones do and which ones don't. ... Even if that option did guarantee that the C99 standard were strictly followed, that does not mean that every compiler out there supports C99 yet. ... discovered sigaction the other day, which is much nicer than signal in that it lets you do the automatic re-registration of handlers, whereas signal does not, and it lets you mask other signals while in the handler. ...
    (alt.lang.asm)
  • Re: memmove crash
    ... library functions, do not get invalid arguments, thus invoking undefined behavior. ... all kinds of stuff that has to be done when that signal handler is called, so I'd have to go through it all and make sure none of it calls any libc functions that are going to do a malloc, and it's not like it's easy to tell which ones do and which ones don't. ... Now if something that compiles with "-ansi" just fine on my Linux system doesn't compile on yours, then I think I definately want to go back to assembly language. ... those automatically re-registering signals are nice. ...
    (alt.lang.asm)
  • Gl1bC L1nuxThreadz ADV1SORY, was Re: [Full-Disclosure] bombings in bali
    ... int sigaction(int sig, const struct sigaction * act, ... struct sigaction newact; ... /* Record that we're in a signal handler and call the user's ... just mask off all signals for signal handling, ...
    (Full-Disclosure)
  • RE: ISS Advisory: Remote Compromise Vulnerability in Apache HTTP Server
    ... Well, a signal handler *is* a way of changing the instruction pointer, so it ... - You have a vulnerability which lets you execute an arbitrary sigaction ... simply messing with the signal handlers for fatal signals so it can't clean ... Note that with sigaction, ...
    (Vuln-Dev)
  • Re: malloc crash solaris 2.6 - signal handler
    ... > application a signal handler?) ... I fixed a bug in this many years ago; signals in Xview get written to ... effect of the libc internal mutex used to protect malloc state. ... fix Xview which had an inherent race in the signal handling code since ...
    (comp.unix.solaris)