Prevent kill signals to childs

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi, i have the this problem, i have process opened with open3, and i
use waitpid in threads to determine if ends, but when i send a SIGINT
(Control-C) the signal propagates to the childs, i need control this
signal and prevent the propagation of the signal to childs, how i can
do that???


Re: Prevent kill signals to childs

Quoted text here. Click to load it

When you press Control-C in most shells, the shell will send SIGINT to
everyone the "process group", or something like that.  If the child uses
POSIX::setsid() to remove itself from the parent's process group, then it
shouldn't receive the signal.

If that doesn't work, you could use a sig handler in the child to trap and
ignore the signal.


-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Re: Prevent kill signals to childs

On Thu, 05 Jun 2008 16:09:04 +0000, xhoster wrote:

Quoted text here. Click to load it

If the OP cannot control the child in this regard, it still can be done,
but it's dirty and tricky. Fork(), setsid() and exec and figure out a way
to keep Open3()s functionality.


Re: Prevent kill signals to childs

Quoted text here. Click to load it

Can you add a SIGINT handler in the child to block
or ignore the signal...?

If not, you could launch the child via a shell
which ignores the signal, eg, in some Unix
shells at least, this'll work:

open3(...., "trap '' 2;/path/to/child") ..

Of course, if you don't catch SIGINT in the
parent, the child appears to get disposed of
in spite of the shell's SIGINT trap... Maybe
it gets a SIGTERM from the O/S when the parent
dies unexpectedly... I don't know.

However, if you trap SIGINT in the parent,
you can confirm that the child has ignored
the signal and is still running by examining

Charles DeRykus

Site Timeline