From: Tim Uckun Date: 2010-10-04T10:24:57+09:00 Subject: Re: having problems with open4 and stuck forked processes On Sat, Sep 25, 2010 at 9:05 PM, Robert Klemme wrote: > On 25.09.2010 00:25, Tim Uckun wrote: >>> >>> It would be safer to use select() on the data coming from the child to >>> wait for the process to terminate (when you read end-of-file) >> >> But what if the process hangs? >> >> Wouldn't I need to use timeout to check for that anyway? > > Select can be called with a timeout which guarantees that the call returns > in time regardless whether there is any data available. > Hey guys I want to revist this issue because I can't seem to find any documentation on how to do this. What I want to do seem simple enough. I want to shell out to a process which sometimes gets stuck. It won't return at all. It just sits there taking up 100% of the CPU (one of the cores anyway). I just want to make sure that if the process does not end in a reasonable amount of time I want to kill it. So far I have tried wrapping it in a timeout block but that doesn't always trigger for some reason. I have plenty of error handling and have an ensure block which says to kill the process if it exists but nothing I do seems to work. Sooner or later I get a stuck process that hangs around forever till I kill it by hand. Surely there is a simple way to do this. Here is the code I have so far. http://gist.github.com/609119