php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56643 External programs don't exit but become zombies (defunct)
Submitted: 2005-11-13 18:04 UTC Modified: 2007-09-09 11:40 UTC
From: pecl dot bugs at depoll dot de Assigned:
Status: Closed Package: expect (PECL)
PHP Version: 5.0.3 OS: UbuntuBreezy(Linux 2.6.12-9-686)
Private report: No CVE-ID: None
 [2005-11-13 18:04 UTC] pecl dot bugs at depoll dot de
Description:
------------
When executing an external program via the expect:// wrapper everything works as expected except for the "shutdown". The program becomes a zombie and stays in the processlist until Apache is restarted. This does NOT occur when executing the PHP script via command line.

Same happens when executing screen or just something as simple as "echo", leaving the original shell, the program was executed in, as the zombie process.

This might be an PHP or Apache bug but I don't think so, as the problem doesn't occur when using for instance popen().

** PHP version: 5.0.5
'./configure' \
'--prefix=/usr/local' \
'--with-apxs2=/usr/bin/apxs2' \
'--with-config-file-path=/etc' \
'--with-mysql=/usr' \
'--enable-mbstring' \
'--with-gd' \
'--with-zlib' \
'--with-mysqli' \
'--with-gettext' \
'--with-mcrypt' \
'--with-imap' \
'--with-openssl' \
'--with-kerberos' \
'--with-imap-ssl' \
'--enable-ftp' \
'--with-freetype' \
'--with-freetype-dir=/usr/include/freetype2' \
'--with-jpeg' \
'--enable-sockets' \
'--enable-memory-limit' \
'--enable-pcntl' \
'--enable-pty' \
'--enable-shmop' \
'--enable-sysvsem' \
'--enable-sysvshm' \
'--enable-sigchild'
libexpect version: 5.43
Apache version: 2.0.54

Same happens when executing screen 

Reproduce code:
---------------
<?php

$shell = fopen('expect://bash', 'r+');
sleep(5);
fwrite($shell, "exit\n");
sleep(5);
fclose($shell);

// following seems to close the shell (fclose() fails afterwards) but the shell becomes a zombie nevertheless
$shell = fopen('expect://echo', 'r+');
sleep(5);
fwrite($shell, "exit\n");
sleep(5);
fclose($shell);

?>

Expected result:
----------------
A bash process starts and just to get terminated again.

Actual result:
--------------
% ps aux | grep defunct
www-data 21449  0.0  0.0      0     0 ?        Zs   23:53   0:00 [bash] <defunct>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-13 18:09 UTC] pecl dot bugs at depoll dot de
Restarting Apache leads to a proper "destruction" of the processes but that of course isn't even close to a fix but just a dirty workaround.
 [2007-09-06 15:35 UTC] maport1 at uky dot edu
I have an identical problem, using the latest version of the Expect extension.  Spawned processes become zombies, and are not cleared until Apache is restarted.
 [2007-09-09 11:40 UTC] spektom at gmail dot com
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 10:01:26 2019 UTC