Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
go ahead... be a heretic
 
PerlMonks  

Ensuring signal receipt under Linux

by jpfarmer (Pilgrim)
on Jan 24, 2006 at 12:03 UTC ( [id://525242]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

jpfarmer has asked for the wisdom of the Perl Monks concerning the following question:

Greetings fellow monks!

I have an application that forks off a continually-running child process. In the course of the child's life, it frequently shells out to run different applications. As a result, it will sometimes disregard signals (INT and HUP) if the signal is sent while the child is in one of these processes.

Is there a way to correct this behavior? I would like it to wait for the forked application to complete then perform whatever the signal requires. Can I only do this by forking another child process to execute the system command?

Here is how I'm handling the interrupt now:

$SIG{'INT'} = 'stop_child'; sub stop_child{ print "Recieved stop signal.\n"; exit; }

Replies are listed 'Best First'.
Re: Ensuring signal receipt under Linux
by chrism01 (Friar) on Jan 24, 2006 at 18:09 UTC
    You could use your sigtrap fn to record the fact (in a global/pkg var) that the sig was received, then when convenient, use the perl built in 'kill' to send/fwd the prev received sig to whichever process.
    It's not quite clear from your qn whether the child fork completes ever, or whether you mean when the shelled-out call completes...
    Remember to clear the pkg var when you do deliver the sig.
    Cheers
    Chris

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://525242]
Approved by Paladin
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.