Reputation: 893
I have a process (call it process A) which kicks off several instances of process B. When debugging process A in gdb, if I use Ctrl+C to pause process A with a SIGINT, all the child B processes get killed, so I have to restart the whole thing once I'm done debugging process A. Is there a way to prevent gdb from sending SIGINT to the child processes, thus killing them (at least I assume that's what's happening)? If so, what is it?
Note that I do NOT have the source code for process B (so I cannot add some code to handle SIGINT). The process interfaces are in C++.
Upvotes: 0
Views: 496
Reputation: 7923
Try
signal(SIGINT, SIG_IGN);
in A. According to man signal
(emphasis mine),
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.
Upvotes: 2