The idea is that once your program receives a SEGV signal - you cannot
be sure why it happened. it could have happened because the memory used
by the logger contained a dangling pointer - and then trying to print
the log from the SEGV handler could result an endless loop. the least
you could do is set SIGSEGV to ignore before printing the log - although
i am not sure that invoking a system call from within a signal handler
is a good idea to begin with.
by the way - if the system is set to generate core files for daemons,
then at least in theory it is possible to write some gdb macros that
will extract the non-flushed part of the logs from the core file -
assuming the shared-memory segment is still available. i need to check
if it's possible to make gdb re-attach to that segment while handling
the core file (generally this is not possible since you cannot run
function without attaching to a running process. however - there's a
project that allows re-creating a process around a core file - and
perhaps using that project this will become possible).
--guy
--guy