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

From: Date: Mon, 01 Jun 2009 10:15:16 +0000
Subject: Re: spawning a process that uses pipes - doesn't terminatewhen webpage download is canceled
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-293410@lists.php.net to get a copy of this message
----- Original Message ----- From: "Robert Cummings" <robert@interjinn.com> To: "flint" <fmillion@gmail.com> Cc: "PHP-General List" <php-general@lists.php.net> Sent: Sunday, May 31, 2009 10:15 PM Subject: Re: [PHP] 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


« previous php.general (#293410) next »