The dup() is there "just-in-case" something breaks during PHP shutdown.
I don't remember now exactly what the potential problem(s) might have
been, so perhaps the dup is overly cautious.

So, I don't have a problem eliminating it, unless someone points out
a good reason to keep it :-)

--Wez.

----- Original Message ----- 
From: "Bernard Fouché" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, April 02, 2004 10:24 AM
Subject: [PHP-DEV] CLI: constants STDIN, STDOUT & STDERR do not point to df
0, 1 & 2


> 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.
>
> Can this be fixed or should I consider using another solution? (coding my
> script in C ;-( )
>
> Regards,
>
>   Bernard
>
> -- 
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to