NO CARRIER

Computers, Science, Technology, Xen Virtualization, Hosting, Photography, The Internet, Geekdom And More

Crazy signal stuff

Posted on | September 20, 2008 | No Comments

I recently wrote a program that set up signal handlers as the first order of business. Not just SIGHUP and SIGINT, but also floating point exceptions, segmentation faults, double frees, etc.

Then I started logging (after establishing the handlers via sigaction()). In my logging routine, there is a shared static buffer s, which gets allocated by my logging init function. I had a bug where I logged before allocating s (logging before the logging init function), which of course threw a segmentation fault when vsnprintf() operated on s.

This did not invoke the signal handler, at all, even though all calls to sigaction() were successful and nothing was ignored.

Then when I put a 5 second sleep after the function that sets signal handlers, everything worked fine. Maybe sigaction() should block .. I never saw this using just signal().

Comments

Leave a Reply





  • Monkey Plus Typewriter
  • Stack Overflow

  • Me According To Ohloh

  • Meta