View previous topic :: View next topic |
Author |
Message |
cmxflash -
Joined: 11 Dec 2004 Posts: 872
|
Posted: Wed Sep 14, 2005 3:52 pm Post subject: Need help with exec("x"); |
|
|
Okay, so I'm using exec("x"); in some of my scripts, the thing is that the page times out if X (the executed program) dosn't exit. Is there any way to limit the time that a program can be executed with PHP? I still want the program to keep running though... |
|
Back to top |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Wed Sep 14, 2005 4:07 pm Post subject: |
|
|
ignore_user_abort() may help you.
The first example in the functions page in the PHP manual especially. _________________
 |
|
Back to top |
 |
 |
cmxflash -
Joined: 11 Dec 2004 Posts: 872
|
Posted: Thu Sep 15, 2005 9:08 am Post subject: |
|
|
Well, I tried that command, and it didn't work. Any other ideas?
X didn't get executed.
Edit: I'm going to write this function in C instead of PHP. |
|
Back to top |
|
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Thu Sep 15, 2005 4:30 pm Post subject: Re: Need help with exec("x"); |
|
|
cmxflash wrote: | Okay, so I'm using exec("x"); in some of my scripts, the thing is that the page times out if X (the executed program) dosn't exit. Is there any way to limit the time that a program can be executed with PHP? I still want the program to keep running though... |
You can write you own version of exec() with timeout by combining the following PHP commands:
popen()
stream_set_blocking()
stream_select()
fread()
The idea is to get a create a child process with popen() and get a stream handle to its input and output. Set the output stream to the non-blocking mode using stream_set_blocking() and then wait for data availability on this stream using stream_select(). stream_select() has a timeout value so you'll be notified when new data arrives or when the waiting delay is over. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
 |
cmxflash -
Joined: 11 Dec 2004 Posts: 872
|
Posted: Thu Sep 15, 2005 10:56 pm Post subject: |
|
|
Well, I've already written a C-program that starts the program i want, but thanks anyway. |
|
Back to top |
|
 |
|