#24858 [Opn->Bgs]: proc_open() leaves zombie processes if user cancels page load
ID: 24858
User updated by: jr-php2 at quo dot to
Reported By: jr-php2 at quo dot to
-Status: Open
+Status: Bogus
Bug Type: Program Execution
Operating System: Red Hat Linux 9.0, kernel 2.4.21
PHP Version: 4.3.3RC2-dev
New Comment:
Good news:
I found I couldn't reproduce the problem after downgrading Apache to
1.3.27. Then I came across this bug report for Apache 1.3.28:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21737
I applied the second patch there, and so far haven't had any more
lingering zombie processes.
Why I could only reproduce the problem when I used proc_open() remains
a mystery... Sorry for the false alarm.
Previous Comments:
------------------------------------------------------------------------
[2003-07-30 02:42:52] jr-php2 at quo dot to
Same problem exists in php4-STABLE-200307300530.
------------------------------------------------------------------------
[2003-07-30 02:11:46] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
------------------------------------------------------------------------
[2003-07-29 14:36:01] jr-php2 at quo dot to
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?
------------------------------------------------------------------------
[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
Thread (5 messages)