Ankit
Ankit

Reputation: 11

Can the parent process know if the child is coredumping

In Linux, to my understanding, in a parent process, wait call will return only when child process has died. In case a child decides to dump core, the wait will only return after coredump has occurred.

Is there a way in Linux for the parent to know whether child is dumping core, and if yes, then take other actions(some Event publishing), and on the side, child can continue dumping core. That is, is there a way for child or kernel to inform the parent before starting to dump core, that it has died and will dump core now?

Thanks

Upvotes: 1

Views: 665

Answers (1)

fukanchik
fukanchik

Reputation: 2865

man core:

Piping core dumps to a program

 Since kernel 2.6.19, Linux supports an alternate syntax for the
 /proc/sys/kernel/core_pattern file.  If the first character of this
 file is a pipe symbol (|), then the remainder of the line is
 interpreted as a program to be executed.  Instead of being written to
 a disk file, the core dump is given as standard input to the program.

Example:

cat /proc/sys/kernel/core_pattern 
|/usr/lib/systemd/systemd-coredump %p %u %g %s %t %e

This means you can configure some program which would accept core dumps and notify whoever is interested.

Upvotes: 1

Related Questions