I am unsure whether this is the C library or some other stuff which dumps contents to core file and make a program Exit. What i mean here is that is the glibc or libc handles the SIGSEGV and creates the core dump in the handler function ? Please explain.
In linux, the kernel process execution and signal handling mechanisms are responsible.
http://lxr.linux.no/#linux+v2.6.32/fs/exec.c#L1752
void do_coredump(long signr, int exit_code, struct pt_regs *regs)
{
...
http://lxr.linux.no/#linux+v2.6.32/kernel/signal.c#L1926
if (sig_kernel_coredump(signr)) {
if (print_fatal_signals)
print_fatal_signal(regs, info->si_signo);
/*
* If it was able to dump core, this kills all
* other threads in the group and synchronizes with
* their demise. If we lost the race with another
* thread getting here, it set group_exit_code
* first and our do_group_exit call below will use
* that value and ignore the one we pass it.
*/
do_coredump(info->si_signo, info->si_signo, regs);
When there's no other handler, the kernel will generate the core file if ulimit -c is greater than 0 for the process.
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