Re: hook SIGSEGV

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2014-05-10 21:46:01 (+0800), net.study.sea@xxxxxxxxx <net.study.sea@xxxxxxxxx> wrote:
>      I want to know is it possible to hook SIGSEGV to restart the
>      thread which the signal is sent to,without restart the whole
>      process? And record the place where has caused this signal?
> 
Yes, as others have already pointed out, you can hook SIGSEGV like any
other signal.

You're not going to be able to save the process any more, but you can
still collect some useful information.

I've found it very useful to have a SIGSEGV (and SIGPIPE, SIGABRT,
SIGFPE, SIGILL) handler which logs a backtrace (look at 'man backtrace')
to syslog. Very useful for debugging on targets where core dumps are
impractical.

Others have also pointed out that it might no longer be safe to call
printf() or malloc() there. That's true, but usually it's OK, and if it
turns out that it wasn't ... Well, you were crashing anyway.

Regards,
Kristof

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux