ID: 24858
User updated by: jr-php2 at quo dot to
Reported By: jr-php2 at quo dot to
Status: Open
Bug Type: Program Execution
Operating System: Red Hat Linux 9.0, kernel 2.4.21
PHP Version: 4.3.2
New Comment:
FYI, I tried adding a "ignore_user_abort(1);" call to the top of the
script but it did not help. I guess ignore_user_abort() probably has no
effect when PHP is used as a CGI binary?
Previous Comments:
------------------------------------------------------------------------
[2003-07-29 13:51:05] jr-php2 at quo dot to
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 this bug report at http://bugs.php.net/?id=24858&edit=1