Re: How to interrupt function execution after X seconds?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 9 Jun 2015 at 22:00 helices <mike@xxxxxxxxxxxxxxx> wrote:

> I execute a system call via proc_open() that usually completes in less than
> one minute
>
> Sometimes, it hangs for many hours
>
> I want to exit this parent script after thirty (30) minutes with the error
> description on STDERR and I also want that system call process killed at
> this point
>
> Although, a test script using ticks and pcntl_alarm(1800) works using a
> while() loop, this does NOT work with my production system call
>
> What am I missing?
>
> Please, advise. Thank you
>

If it's a CLI script, and it sounds like it is, I would fork before calling
proc_open in the child, and have the parent watch the PID. It can then
terminate the child. I'm not certain that will kill the process that was
opened by proc_open, but that would be where I'd start.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux