Reputation: 43
According to the man page for sigaction, if we use it with SIGCHLD then in our handler function - this is if we use void (*sa_sigaction)(int, siginfo_t *, void *);
the si_code
member of the siginfo_t
structure should contain the reason the signal was sent.
I am interested in these reasons...
CLD_EXITED
CLD_KILLED
CLD_DUMPED
Now my question is... even if the child exited abnormally (i.e by executing buggy code to
cause a crash) i still get CLD_EXITED
. I assumed I should get CLD_DUMPED
instead.
As for CLD_KILLED
, if I kill a child process, I get this one correctly.
What am I missing? In my parent process, I need to know if any of the child processes terminate abruptly.
I am causing the abrupt error by trying to write to a null pointer but I need to know of any kind of abnormal termination. It is not necessary to know exactly what or how it happened.
When is the CLD_DUMPED
generated?
Kind Regards.
Upvotes: 2
Views: 1772
Reputation: 215637
Rather than the si_code
given to the signal handler, you should simply be looking at the exit status from waitpid
(or one of the other wait
-family functions) to determine the cause of exit. The macros W*
from sys/wait.h
, when applied to the status int
, will tell you the cause of termination.
Upvotes: 1
Reputation: 10435
AFAIK, CLD_DUMPED
is caused when the process dumps core.
Upvotes: 0