php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27865 CLI PHP: STDIN/OUT/ERR are not the good fd's
Submitted: 2004-04-05 06:07 UTC Modified: 2004-04-19 19:41 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: bernard at kuantic dot com Assigned: wez (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.0.0RC1 OS: Linux Fedora Core 1
Private report: No CVE-ID: None
 [2004-04-05 06:07 UTC] bernard at kuantic dot com
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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-19 19:41 UTC] wez@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 08:01:29 2024 UTC