Re: spawning a process that uses pipes - doesn't terminatewhen webpage download is canceled

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

 




----- Original Message ----- From: "Robert Cummings" <robert@xxxxxxxxxxxxx>
To: "flint" <fmillion@xxxxxxxxx>
Cc: "PHP-General List" <php-general@xxxxxxxxxxxxx>
Sent: Sunday, May 31, 2009 10:15 PM
Subject: Re: spawning a process that uses pipes - doesn't terminatewhen webpage download is canceled

I'm already doing something like that... here's what I have basically

$o = popen($cmd);
while (!feof($o)) {
 $buffer = fread($o,4096);
 echo $p;
}
exit();

Ok so I can add in the statements to stop auto aborting, use connection aborted... but how do i kill the process chain itself? If I simply pclose the process it has the same effect - the other spawned processes keep running. I figured out what's happening is the lame process keeps going utnil it finishes, and apparently is sending its data to the proverbial bit bucket... and in a process tree it moves from being under the http process to being under init itself...

fm

Use something else to pass the data back to the user... popen() comes to
mind or proc_open(). Then disable auto abort on user disconnect via
ignore_user_abort(). Then after sending periodic data chunks, check the
user connection status via connection_aborted(). If your script finds
that the user has aborted, then kill all the processes in the pipeline
from the PHP script before finally aborting the PHP script itself.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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