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?