| 
	
 | 
 Posted by Colin McKinnon on 08/29/05 22:49 
ZeldorBlat wrote: 
 
>>From http://www.php.net/manual/en/function.exec.php 
>  
> "Note: If you start a program using this function and want to leave it 
> running in the background, you have to make sure that the output of 
> that program is redirected to a file or some other output stream or 
> else PHP will hang until the execution of the program ends." 
 
Won't work - you haven't dissocciated the new process from the parent. 
(Might work on a non-unix system). The webserver won't send an EOF until 
the chid process terminates. You could call it from a function registered 
using register_shutdown_function() to run after the socket is closed but 
that's still messy as the the webserver process hangs around to wait for it 
to exit. 
 
You can create a separate process group easily using the 'at' command. 
 
$run_in_background=`echo $name_of_script | at now`; 
 
Chris wrote: 
  
> Is it possible to close an HTTP connection in the middle of a php 
> script? 
 
If the above didn't answer your question (there are instances where you 
might want to disconnect from the browser but continue with the current 
thread of execution) then repost - there's an answer to this as well, but 
it really starts getting complicated and you need to start working with 
proxy scripts and sockets. 
 
C.
 
  
Navigation:
[Reply to this message] 
 |