Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Killing a hanging child process

by sgt (Deacon)
on Sep 13, 2006 at 22:43 UTC ( [id://572833]=note: print w/replies, xml ) Need Help??


in reply to Killing a hanging child process

It is not an easy problem in the general case

I implemented in C a system with time-out and a command ish wich I use in production. It has one limitation and there is a trick: I use setpgid() in the father and the child (you need both to avoid a race condition), this way I can kill(pgid), which actually kills everything the exec()ed process starts ...except if it itself uses setpgid() like daemons (this is the limitation ;)</>

using the POSIX module, I think a pure perl solution is not too complicated (a line by line translation, but hey if it works...) if you want the code contact me at sgt19DELETE@tidALLCAPS.es

Replies are listed 'Best First'.
Re^2: Killing a hanging child process
by chb (Deacon) on Dec 22, 2006 at 08:36 UTC
    I need to kill an exec()ed process together with all processes it starts, too. I would like to use the setpgid() trick, but I don't understand why I have to use setpgid() in the father process. Why is it a race condition if I use setpgid() in the child only?

Log In?
Username:
Password:

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

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

    No recent polls found