gdb:中断 运行 进程而不杀死子进程
gdb: interrupt running process without killing child processes
我有一个进程(称之为进程 A)启动进程 B 的多个实例。在 gdb 中调试进程 A 时,如果我使用 Ctrl+C 暂停进程 A 并发出 SIGINT,所有子进程 B被杀死,所以我必须在完成调试过程 A 后重新启动整个过程。有没有办法阻止 gdb 向子进程发送 SIGINT,从而杀死它们(至少我假设这是正在发生的事情)?如果有,那是什么?
请注意,我没有进程 B 的源代码(因此我无法添加一些代码来处理 SIGINT)。进程接口使用 C++。
尝试
signal(SIGINT, SIG_IGN);
在 A 中。根据 man signal
(强调我的),
A child created via fork(2) inherits a copy of its parent's signal dispositions. During an execve(2), the dispositions of handled signals are reset to the default; the dispositions of ignored signals are left unchanged.
我有一个进程(称之为进程 A)启动进程 B 的多个实例。在 gdb 中调试进程 A 时,如果我使用 Ctrl+C 暂停进程 A 并发出 SIGINT,所有子进程 B被杀死,所以我必须在完成调试过程 A 后重新启动整个过程。有没有办法阻止 gdb 向子进程发送 SIGINT,从而杀死它们(至少我假设这是正在发生的事情)?如果有,那是什么?
请注意,我没有进程 B 的源代码(因此我无法添加一些代码来处理 SIGINT)。进程接口使用 C++。
尝试
signal(SIGINT, SIG_IGN);
在 A 中。根据 man signal
(强调我的),
A child created via fork(2) inherits a copy of its parent's signal dispositions. During an execve(2), the dispositions of handled signals are reset to the default; the dispositions of ignored signals are left unchanged.