I had put a simple trap instruction to simulate a breakpoint on the inferior, but when this instruction is reached I got a CLD_KILLED instead of CLD_SIGTRAP, like the one below.
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=12668, si_uid=10157, si_status=SIGTRAP, si_utime=2692, si_stime=875}
It seems that gdb is able to prevent SIGTRAP to kill the inferior by using the command "handle SIGSTOP nopass".
How can I do it in C?
Thanks
According to the man page, https://www.freebsd.org/cgi/man.cgi?query=siginfo&sektion=3&apropos=0&manpath=FreeBSD+7.1-RELEASE
SIGCHLD
si_pid child process ID
si_status exit value or signal; if si_code is equal to
CLD_EXITED, then it is equal to the exit
value of the child process, otherwise, it is
equal to a signal that caused the child
process to change state.
In your case si_code=CLD_KILLED
so the clause si_status
[...] is equal to a signal that caused the child to change state.
Thus si_status=SIGTRAP
is the information you're looking for.
If you had ptrace
your child you would have gotten a SIGTRAP
instead.