NYCPHP Meetup

NYPHP.org

[nycphp-talk] system() call timeout

Andrew Yochum andrew at plexpod.com
Wed Oct 12 15:28:10 EDT 2005


On Wed, Oct 12, 2005 at 01:15:19PM -0500, Jeffrey O. Stevison wrote:
> But if the command hangs, the only thing that the time command will  
> do is record how long the program is 'executing' or not for that  
> matter.  I need to term the offensive command and return a code that  
> this has happened.  The reason being I don't want to wait for the  
> system to time out the command as it takes too long to time out.  I  
> would know in a matter of seconds rather than the systems minutes  
> whether the command is hung or not.

Gotcha.

One method might be to use the pcntl_* functions to fork a child, exec the "ls
-la" and wait for the child to exit using a non-blocking waitpid in a loop,
killing the proc if it takes to long or moving on to other business when it
returns.  

HTH,
Andrew
-- 
Andrew Yochum
Plexpod
andrew at plexpod.com
718-360-0879



More information about the talk mailing list