|
Posted by Felipe Alcacibar B on June 5, 2008, 1:04 am
Please log in for more thread options
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???
Cheers:
Felipe
|
|
Posted by xhoster on June 5, 2008, 12:09 pm
Please log in for more thread options
show/hide quoted text
> 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???
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.
Xho
--
-------------------- 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.
|
|
Posted by Martijn Lievaart on June 6, 2008, 3:11 am
Please log in for more thread options On Thu, 05 Jun 2008 16:09:04 +0000, xhoster wrote:
show/hide quoted text
>> 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???
>
> 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 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.
M4
|
|
Posted by comp.llang.perl.moderated on June 5, 2008, 5:54 pm
Please log in for more thread options show/hide quoted text
> 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???
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
ps(1).
--
Charles DeRykus
|
| Similar Threads | Posted | | mod_perl: sharing data across httpd childs ? | October 15, 2008, 4:36 am |
| open3 and signals | September 20, 2004, 8:43 pm |
| traping signals | April 26, 2005, 7:55 am |
| Mod_perl and Signals | May 17, 2007, 5:17 pm |
| ithreads + signals on modern Unices | February 8, 2005, 12:31 am |
| FAQ 8.13 How do I trap control characters/signals? | March 11, 2005, 12:03 pm |
| FAQ 8.13 How do I trap control characters/signals? | May 23, 2005, 5:03 am |
| FAQ 8.13 How do I trap control characters/signals? | August 7, 2005, 10:03 pm |
| FAQ 8.13 How do I trap control characters/signals? | September 21, 2005, 4:03 am |
| FAQ 8.13 How do I trap control characters/signals? | November 2, 2005, 5:03 pm |
|
> 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???