我已经设置了一个简单的陷阱指令来模拟下级的断点,但是当达到此指令时,我得到了一个CLD_KILLED而不是CLD_SIGTRAP,如下所示。
--- SIGCHLD {si_signo = SIGCHLD,si_code = CLD_KILLED,si_pid = 12668,si_uid = 10157,si_status = SIGTRAP,si_utime = 2692,si_stime = 875}
似乎gdb能够通过使用命令“handle SIGSTOP nopass”来阻止SIGTRAP杀死下级。
我怎样才能在C中完成?
由于
答案 0 :(得分:0)
根据手册页, 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.
在您的情况si_code=CLD_KILLED
中, si_status
[...]这一条款等于导致孩子改变状态的信号。
因此si_status=SIGTRAP
是您正在寻找的信息。
如果您的孩子有ptrace
,那么您将获得SIGTRAP
。