Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8890 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25726 invoked by uid 1010); 2 Apr 2004 09:24:19 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 25662 invoked from network); 2 Apr 2004 09:24:18 -0000 Received: from unknown (HELO gw.kuantic.com) (192.70.34.228) by pb1.pair.com with SMTP; 2 Apr 2004 09:24:18 -0000 Received: from zobilamouche ([10.0.0.4]) by gw.kuantic.com (8.12.10/8.12.10) with SMTP id i329OG4e011618 for ; Fri, 2 Apr 2004 11:24:16 +0200 Message-ID: <00f601c41894$44c5b2d0$0400000a@zobilamouche> To: Date: Fri, 2 Apr 2004 11:24:14 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Subject: CLI: constants STDIN, STDOUT & STDERR do not point to df 0, 1 & 2 From: bernard.fouche@kuantic.com (=?iso-8859-1?Q?Bernard_Fouch=E9?=) 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