From:             jr-php2 at quo dot to
Operating system: Red Hat Linux 9.0, kernel 2.4.21
PHP version:      4.3.2
PHP Bug Type:     Program Execution
Bug description:  proc_open() leaves zombie processes if user cancels page load

Description:
------------
Apache version: 1.3.28
PHP version: 4.3.2, used as a CGI binary:
./configure --prefix=/usr/local/php-cgi --enable-track-vars --with-mysql
--with-zlib --enable-discard-path

I have found that if page loading is cancelled by the user (e.g. by
closing the Internet Explorer window) before fclose() & proc_close() are
called, a zombie process is left behind.

Try the code below (save it as 'testx.cgi'). During normal execution,
you'll see this:

27551 ?        S      0:00 /usr/local/php-cgi/bin/php testx.cgi
22800 ?        Z      0:00 [ls <defunct>]

If you let the page load completely, both processes go away from the
process list.

If, however, you close the browser window before the sleep() call
finishes, about 70% of the time a zombie process is left behind:

27551 ?        Z      0:00 [testx.cgi <defunct>]

I have to restart Apache (1.3.28) to kill this process.

Reproduce code:
---------------
#!/usr/local/php-cgi/bin/php
<?php
$descriptorspec = array(
   0 => array("pipe", "r"),  // stdin is a pipe that the child will read
from
   1 => array("pipe", "w"),  // stdout is a pipe that the child will write
to
   2 => array("file", "/dev/null", "a"), // stderr is a file to write to
);
$process = proc_open('/bin/ls -al /tmp', $descriptorspec, $pipes);
if (!is_resource($process)) die("Error: proc_open failed");

sleep(10);

fclose($pipes[0]);

fpassthru($pipes[1]);
fclose($pipes[1]);

proc_close($process);
?>

Expected result:
----------------
There should be no zombie process left over when the user cancels the page
load.


-- 
Edit bug report at http://bugs.php.net/?id=24858&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=24858&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=24858&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=24858&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24858&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24858&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24858&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24858&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24858&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24858&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24858&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24858&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24858&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24858&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24858&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24858&r=gnused

Reply via email to