I was just wondering how segmentation faults might get reported.
Which one of these reports the segmentation faults (just an example), and how?
The process will just die, so obviously it cannot report it.
This is actually false. It is possible to install a SIGSEGV
handler to replace the default one, which simply dumps core and dies. A preload library can do so to catch a segmentation violation and use the limited facilities available to notify another process running on the system of what has happened before exiting.
If you take a look at the functions wait()
or waitpid()
, you will find that one of the bits in the exit status indicates a core dump. The POSIX specification mentions WIFSIGNALED
[sic] and WTERMSIG
to get the signal that terminated the process. The POSIX specification doesn't mention it, but on Mac OS X (10.7.4) for example, there's a WCOREDUMP()
macro to test whether a core file was created.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With