Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: (Zigster) Timing out shell commands (paranoia)

by zigster (Hermit)
on May 02, 2001 at 12:34 UTC ( #77265=note: print w/ replies, xml ) Need Help??


in reply to Timing out shell commands (paranoia)

Not sure if I follow what you mean, in the second case the reason it is more effective is not because of the pipe but because you store the process id of the child and send a sigkill to that child when you want it to die. I do agree that having a pipe is an unrequired overhead and seems a tad ugly for what you want to achieve. I would recomend that you drop back to basics and fork/exec your child. Fork will return the pid of the child to allow you to kill it later. Just keep in mind that if you start using fork/exec you need to keep track of zombie processes (all described in fork).

As an asside I would Strongly recomend that you do not use kill 9, this sends a sigkill to your child process. SigKill cannot be trapped by the process to allow clean sutdown. The chance that you will leave your child in a mess is high. Send sigquit (3) this is a nice gentle tap on the head requesting the child die. If you feel that it is important to ensure the child dies and you are concerned that the child may ignore sigquit then use waitpid to ensure that the process dies, send sigkill iFF the child refuses to die. --

Zigster


Comment on Re: (Zigster) Timing out shell commands (paranoia)
Re: Re: (Zigster) Timing out shell commands (paranoia)
by bluto (Curate) on May 02, 2001 at 22:06 UTC
    Your "gentle tap" suggestion is a good idea (esp if timeouts are short). I get sloppy with kill 9, since I tend to give long timeouts usually just as sanity checks. If they ever trigger, the child is usually at the point where anything other than 9 won't do much. Thanks.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2014-09-16 12:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (16 votes), past polls