php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38199 fclose() unable to close STDOUT and STDERR
Submitted: 2006-07-24 22:28 UTC Modified: 2006-08-28 17:15 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: vvalenti at hdesd dot k12 dot or dot us Assigned:
Status: Closed Package: Streams related
PHP Version: 5.1.4 OS: Linux 2.6.9-34.0.2.ELsmp (RHEL4)
Private report: No CVE-ID: None
 [2006-07-24 22:28 UTC] vvalenti at hdesd dot k12 dot or dot us
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-24 12:25 UTC] tsc at netuse dot de
I have the same bug under solaris 9 and Version 5.1.5.
 [2006-08-28 17:15 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 09:01:32 2024 UTC