Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: browser cancels request-> forked procs die?

by jorg (Friar)
on Nov 26, 2003 at 16:29 UTC ( [id://310382]=note: 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.


in reply to Re: browser cancels request-> forked procs die?
in thread browser cancels request-> forked procs die?

ok point taken. So what can I do to prevent that these processes will run forever? There is an odd case that the programs i'm calling go into an endless loop. Can i do a timeout of some sort, and then kill the process off?


Jorg

"Do or do not, there is no try" -- Yoda
  • Comment on Re: Re: browser cancels request-> forked procs die?

Replies are listed 'Best First'.
Re: Re: Re: browser cancels request-> forked procs die?
by mpeppler (Vicar) on Nov 26, 2003 at 17:07 UTC
    It's a little hard to say off-hand as I don't know what your subprocess does. If you have control over the subprocesses source then you could put an alarm in its code and terminate it if it runs for more than X seconds. Or you could do the same thing in the parent (your CGI/modperl handler) where you could do something like (pseudo code):
    $SIG{ALRM} = sub { die 'Timeout'; }; alarm( some decent duration ); eval { fork the child here wait for the child (waitpid() or similar) if the child returns reset the alarm (alarm(0)) }; if($@) { if($@ =~ /Timeout/) { # child exceeded authorized run time, so kill it kill(15, $child); } else { handle other fatal problems.... } }
    It's up to you to determine what amount of time your child process should normally run, so that you don't interrupt a normally executing process.

    Michael

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://310382]
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.