STDIN/OUT/ERR are not the good fd's
| 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 |
|
||||||||||
| 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 commits
[2004-04-19 19:41 UTC] wez@php.net