Need help with exec("x");

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Wed Sep 14, 2005 3:52 pm    Post subject: Need help with exec("x"); Reply with quote

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 View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Wed Sep 14, 2005 4:07 pm    Post subject: Reply with quote

ignore_user_abort() may help you.

The first example in the functions page in the PHP manual especially.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Thu Sep 15, 2005 9:08 am    Post subject: Reply with quote

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 View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Thu Sep 15, 2005 4:30 pm    Post subject: Re: Need help with exec("x"); Reply with quote

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 View user's profile Send private message Send e-mail
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Thu Sep 15, 2005 10:56 pm    Post subject: Reply with quote

Well, I've already written a C-program that starts the program i want, but thanks anyway.
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group