#49015 [Bgs]: PHP doesn't close STDIN,STDOUT,STDERR correct.
ID: 49015
User updated by: tsc at netuse dot de
Reported By: tsc at netuse dot de
Status: Bogus
Bug Type: *Directory/Filesystem functions
Operating System: SUSE LINUX 10.0
PHP Version: 5.3.0
New Comment:
Ok, but i have the problem, that STDOUT isn't defined when i call php
from cli.
My main problem is, that i want to damonize my php script and
STDOUT,STDIN,STDERR wouldn't closed correctly.
Here is my test Script:
<?php
/* This now fails..*/
fwrite (STDOUT, "Test");
fclose(STDOUT);
/* but this still works: */
echo "Stdout still open\n";
?>
Here the Output:
./php -n test.php
X-Powered-By: PHP/5.3.0
Content-type: text/html
<br />
<b>Warning</b>: fwrite() expects parameter 1 to be resource, string
given in <b>/srv/www/wwwenv3.0/sbin/test.php</b> on line <b>5</b><br
/>
<br />
<b>Warning</b>: fclose() expects parameter 1 to be resource, string
given in <b>/srv/www/wwwenv3.0/sbin/test.php</b> on line <b>6</b><br
/>
Stdout still open
Previous Comments:
------------------------------------------------------------------------
[2009-07-22 20:10:17] jani@php.net
You're not closing stdout there. You're closing stream opened to
php://stdout which is different to what PHP itself uses, a.k.a. STDOUT.
See also bug #44217
------------------------------------------------------------------------
[2009-07-22 13:43:02] tsc at netuse dot de
Description:
------------
Description:
------------
This is the same bug as reported and fixed for PHP5
http://bugs.php.net/bug.php?id=27865 and 32107 ,
but is still present
in 5.3.0.
PHP doesn't close STDIN,STDOUT,STDERR correct.
I have the same Issues on Ubuntu 6 LTS.
Reproduce code:
---------------
<?php
$stdout = fopen("php://stdout",w);
fclose($stdout);
/* This now fails..*/
fwrite ($stdout, "Test");
/* but this still works: */
echo "Stdout still open\n";
/*
* Standard output is still open.
* The process is therefore unable to detach from its terminal.
* See PHP Bug #27865,32107 (PHP5, fixed)
*/
?>
Expected result:
----------------
X-Powered-By: PHP/5.3.0
Content-type: text/html
<br />
<b>Warning</b>: fwrite(): 3 is not a valid stream resource in
<b>/srv/www/wwwenv3.0/sbin/test_fork.php</b> on line <b>8</b><br />
Stdout still open
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49015&edit=1
Thread (3 messages)