#27865 [NEW]: CLI PHP: STDIN/OUT/ERR are not the good fd's
| From: | bernard at kuantic dot com | Date: | Mon, 05 Apr 2004 10:07:44 +0000 |
| Subject: | #27865 [NEW]: CLI PHP: STDIN/OUT/ERR are not the good fd's | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-57515@lists.php.net to get a copy of this message | ||
From: bernard at kuantic dot com
Operating system: Linux Fedora Core 1
PHP version: 5.0.0RC1
PHP Bug Type: Filesystem function related
Bug description: CLI PHP: STDIN/OUT/ERR are not the good fd's
Description:
------------
Hello.
I'm trying to run a php script from xinetd (Fedora Linux). I need to close
stdin, stdout & stderr since I want to close the socket established with
the caller process (I have a long processing to do locally, I need to
release a remote resource & closing the connection is the only way I can
do it).
I've tried :
fclose(STDIN); fclose(STDOUT); fclose(STDERR);
It does not work, the socket is still up & running.
When I run strace(1), I see that I'm closing fds 4, 5 & 6 (fd 3 is the fd
of the script being read) and not fd 0, 1 & 2.
It seems that CLI PHP calls dup(2) to get duplicates of fd 0, 1 & 2 and so
these 3 fds are totally unreachable from the script itself.
I'm not used to php source code, but I think that the problem comes from
getting constants STDIN, STDOUT & STDERR thru filter code generation used
by "php://stdin" etc. and no provision is done for the first calls:
a dup(2) is automatically used.
So constants STDIN, STDOUT & STDERR are not pointing to the correct fd's,
but dup's.
--
Edit bug report at http://bugs.php.net/?id=27865&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27865&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27865&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27865&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27865&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27865&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27865&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27865&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27865&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27865&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27865&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27865&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27865&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27865&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27865&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27865&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27865&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27865&r=float