From: vvalenti at hdesd dot k12 dot or dot us
Operating system: Linux 2.6.9-34.0.2.ELsmp (RHEL4)
PHP version: 5.1.4
PHP Bug Type: Streams related
Bug description: fclose() unable to close STDOUT and STDERR
Description:
------------
PHP 5.1.4 (cli) looks to be unable to close the STDOUT and STDERR streams
with the fclose() function. My end goal is to be able to write a daemon
that will completely detach from the controlling terminal.
On another note, PHP 5.0.5 (cli) is able to close STDIN and STDOUT, but
not STDERR according to lsof.
Reproduce code:
---------------
#!/usr/local/bin/php -q
<?php
fclose(STDIN);
fclose(STDOUT);
fclose(STDERR);
for (;;) {
sleep(10);
}
?>
Expected result:
----------------
When running lsof to see what files a process has open, I would expect all
three of the standard IO streams (0, 1, 2) to be missing from the output.
Actual result:
--------------
When running the above script and then running lsof on the process, you
can see that FD 1 and 2 are open (0 was closed properly):
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
<snip>
det.php 3465 vince 1u CHR 136,0 2
/dev/pts/0
det.php 3465 vince 2u CHR 136,0 2 /dev/pts/0
--
Edit bug report at http://bugs.php.net/?id=38199&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=38199&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=38199&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=38199&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38199&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=38199&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=38199&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=38199&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=38199&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=38199&r=support
Expected behavior: http://bugs.php.net/fix.php?id=38199&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=38199&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=38199&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38199&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38199&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38199&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=38199&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=38199&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=38199&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=38199&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=38199&r=mysqlcfg