Hi,

sometimes STDIN, STDOUT and STDERR are not defined in cli mode:

~/cvs/php/php-src# ./sapi/cli/php -r 'var_dump (STDERR);'
resource(3) of type (stream)

~/cvs/php/php-src# echo '<?php var_dump(STDERR); ?> ' | ./sapi/cli/php 
string(6) "STDERR"

The attached patch removes the check for the scripts filename and always
registeres the STD*-constants in PHP_MODE_STANDARD.

Certainly it does not make sense to read from STDIN when called the
second way, but it may be necessary to have STDOUT and STDERR defined. 

Also, accessing STDIN does not lead to segfaults or other oddities.

- Alex
Index: sapi/cli/php_cli.c
===================================================================
RCS file: /repository/php-src/sapi/cli/php_cli.c,v
retrieving revision 1.97
diff -u -r1.97 php_cli.c
--- sapi/cli/php_cli.c	1 Aug 2003 16:52:49 -0000	1.97
+++ sapi/cli/php_cli.c	8 Aug 2003 11:30:26 -0000
@@ -904,9 +904,7 @@
 		PG(during_request_startup) = 0;
 		switch (behavior) {
 		case PHP_MODE_STANDARD:
-			if (strcmp(file_handle.filename, "-")) {
-				cli_register_file_handles(TSRMLS_C);
-			}
+			cli_register_file_handles(TSRMLS_C);
 			php_execute_script(&file_handle TSRMLS_CC);
 			exit_status = EG(exit_status);
 			break;
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to