Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

by zigster (Hermit)
on May 02, 2001 at 12:34 UTC ( [id://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)

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://77265]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-23 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found