I wrote: > I've written a signal handler which intercepts run-time > signals such as SIGFPE and SIGSEGV and logs their > occurrence, among other things, to a file. (This is for > monitoring a web application.) > > My question: Is there an easy way to find out where a > signal > originated from? Ideally the file and line of source code, > as with the assert() macro. For example if SIGSEGV is > raised, it would be very useful to know whereabouts in the > code that happened. > > The setup is gcc, C99, Linux.
Some googling reveals that there's probably no easy way. However, there's a difficult way, which involves a stack backtrace. The C code and a detailed description are here: http://www.tlug.org.za/wiki/index.php/Obtaining_a_stack_trace_in_C_upon_SIGSEGV (I haven't actually tried it.) David
