Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How Can I Reliably Cleanup Sockets in a Backgrounded Program?

by Moron (Curate)
on Jul 02, 2007 at 13:20 UTC ( #624435=note: print w/ replies, xml ) Need Help??


in reply to How Can I Reliably Cleanup Sockets in a Backgrounded Program?

$SIG{CHILD} = 'IGNORE' is supposed to be supported for "some systems", but a more reliable solution is a specific reaper - ctrl-f for "fork" within perlipc for details.

__________________________________________________________________________________

^M Free your mind!


Comment on Re: How Can I Reliably Cleanup Sockets in a Backgrounded Program?
Re^2: How Can I Reliably Cleanup Sockets in a Backgrounded Program?
by xarex (Initiate) on Jul 02, 2007 at 13:35 UTC
    Thanks for the reply,
    But i have absolouty no idea what you mean, could you please try to be a little more specific because i am a complete idiot

    Kenny

      I believe Moron meant that your $SIG{CHILD} = 'IGNORE' instruction should be avoiding zombification of your children, but it's not, and that you should read perlipc for more information on how to build a reliable reaper for your dead processes. Something like (from perlipc itself):

      use POSIX ":sys_wait_h"; sub REAPER { my $child; while (($child = waitpid(-1,WNOHANG)) > 0) { $Kid_Status{$child} = $?; } $SIG{CHLD} = \&REAPER; # still loathe sysV } $SIG{CHLD} = \&REAPER; # do something that forks...

      But you should check with him, anyways :-)

      I myself don't think the nohup command will behave as you might expect, and you should look for daemonization solutions for your program to keep working even if you disconnect. Look for "Complete Dissociation of Child from Parent" again in perlipc.

      Hope this helps!

        Yes that is exactly what I meant on both counts - thanks for helping out - I wasn't sure exactly where to start elaborating when someone says they understand zero of what I am saying - it is probable that the OP didn't write the code he is presenting and so difficult to know at what level to start explaining.
        __________________________________________________________________________________

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://624435]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-10-01 18:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (32 votes), past polls