Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:11317 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9877 invoked by uid 1010); 18 Jul 2004 01:43:21 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 9853 invoked from network); 18 Jul 2004 01:43:21 -0000 Received: from unknown (HELO mproxy.gmail.com) (216.239.56.242) by pb1.pair.com with SMTP; 18 Jul 2004 01:43:21 -0000 Received: by mproxy.gmail.com with SMTP id q44so3996228cwc for ; Sat, 17 Jul 2004 18:43:20 -0700 (PDT) Received: by 10.11.118.46 with SMTP id q46mr124321cwc; Sat, 17 Jul 2004 18:43:20 -0700 (PDT) Message-ID: <4e89b4260407171843653f4fa0@mail.gmail.com> Date: Sun, 18 Jul 2004 02:43:20 +0100 To: Johannes Schlueter Cc: internals@lists.php.net In-Reply-To: <200407180210.09034@schlueters.de> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <200407180210.09034@schlueters.de> Subject: Re: [PHP-DEV] [PATCH] Send errors to stderr instead of stdout From: kingwez@gmail.com (Wez Furlong) Two technical points: 1/ You *must not* use php_stream_from_zval except within a PHP_FUNCTION unless you really know what you're doing. Use php_stream_from_zval_no_verify instead, and manually check to see if you ended up with a valid stream pointer. The segfault problem you had was because you were misusing this macro. 2/ Why not simply fprintf(stderr, STR_PRINT(prepend_string) ........ ? and a third SAPI compatibility point: stderr is not consistently handled across SAPI, so stdout is the "best" place for the error output. If your patch were to be accepted, it would require that you check if the active sapi is CLI before sending the output to stderr, instead of piping it into the output buffer. Of course, breaking the test suite for CLI isn't the best news either; it relies on the output ending up in stdout. --Wez. On Sun, 18 Jul 2004 02:10:08 +0200, Johannes Schlueter wrote: > Hi, > > while developping some shell scripts with PHP-cli I've got annoyed that PHP > sends its error messages to STDOUT instead of STDERR so I've written the > attached patch. > > I see two possible problems with this patch where I'm not sure if one of the > is really critical: > - it uses the PHP STDERR constant defined by PHP-cli. If one doesn't use > PHP-cli and defines a constant with this name which is not a stream-resource > PHP segfaults. (How do I check wether a resource is a stream-resource?) > - there are a few tests checking for error messages and at least > ext/standard/tests/file/userstreams.phpt failed for me after applying this > patch but other tests testing for error messages worked and I'm not sure why > they behave different. (some I/O-Buffers?) > > The patch was developped and tested on my i686-pc-linux-gnu box against HEAD. > > johannes > > PS: The PHP version of HEAD is still 5.0.1-dev but should be 5.1.0-dev, since > 5.0.1 is afaik developped in the PHP_5_0 branch. I also added a patch to > update these numbers. > > >