我在网上查了很多资料,都没有说到其他解决办法。
我认为linux不应该会这么弱智,也许是我用错了signal,因此就从kill -0 pid开始逐个尝试,终于发现用kill -18就能杀掉gdb产生的僵尸进程。信号18是SIGCONT,这个信号可以让停在断点上的进程继续运行。我分析原因,认为这是由于:停在断点上的进程不会响应除了SIGCONT之外的任何信号。
维基百科上说:
When SIGSTOP is sent to a process, the usual behaviour is to pause that process in its current state. The process will only resume execution if it is sent the SIGCONT signal. SIGSTOP and SIGCONT are used for job control in the Unix shell, among other purposes. SIGSTOP cannot be caught or ignored.
这证实了我的想法。