com php-src: Fix bug #44217: Output after stdout/stderr closed cause immediate exit with status 0: NEWS UPGRADING.INTERNALS sapi/cli/cli.h
sapi/cli/php_cli.c

From: Date: Tue, 19 Jun 2018 10:15:33 +0000
Subject: com php-src: Fix bug #44217: Output after stdout/stderr closed cause immediate exit with status 0: NEWS UPGRADING.INTERNALS sapi/cli/cli.h
sapi/cli/php_cli.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-102187@lists.php.net to get a copy of this message
Commit: ecc1a7c582bf8de1eaa619ac4451399ed58f502a Author: Robert Lu <robberphex@gmail.com> Fri, 15 Jun 2018 14:08:49 +0800 Committer: Christoph M. Becker <cmbecker69@gmx.de> Tue, 19 Jun 2018 12:15:33 +0200 Parents: 84d7d4e1cc49e657068ddd6f2c57a93165ffb1a5 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ecc1a7c582bf8de1eaa619ac4451399ed58f502a Log: Fix bug #44217: Output after stdout/stderr closed cause immediate exit with status 0 We exit with status 255 instead. Bugs: https://bugs.php.net/44217 Changed paths: M NEWS M UPGRADING.INTERNALS M sapi/cli/cli.h M sapi/cli/php_cli.c Diff: diff --git a/NEWS b/NEWS index 272a925..0c83a85 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,10 @@ PHP NEWS .. Fixed bug #76427 (Segfault in zend_objects_store_put). (Laruence) . Fixed bug #76422 (ftruncate fails on files > 2GB). (Anatol) +- CLI: + . Fixed bug #44217 (Output after stdout/stderr closed cause immediate exit + with status 0). (Robert Lu) + - Date: . Fixed bug #76462 (Undefined property: DateInterval::$f). (Anatol) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index e77fc0b..173729c 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -17,6 +17,7 @@ PHP 7.3 INTERNALS UPGRADE NOTES n. IS_TYPE_COPYABLE o. IS_UNUSED p. VM instruction operands (FETCH_CLASS, FETCH_CONSTANT, CATCH) + q. sapi_cli_single_write() 2. Build system changes a. Unix build system changes @@ -123,6 +124,8 @@ PHP 7.3 INTERNALS UPGRADE NOTES - FETCH_CONSTANT op1<fetch-flags>, op2<name>, result<tmp> - CATCH ext<last-flag>, op1<name>, op2<jump_addr>, result<cv> + q. sapi_cli_single_write() now returns ssize_t instead of size_t. + ======================== 2. Build system changes ======================== diff --git a/sapi/cli/cli.h b/sapi/cli/cli.h index 0a76895..a02d624 100644 --- a/sapi/cli/cli.h +++ b/sapi/cli/cli.h @@ -30,7 +30,7 @@ #endif -extern PHP_CLI_API size_t sapi_cli_single_write(const char *str, size_t str_length); +extern PHP_CLI_API ssize_t sapi_cli_single_write(const char *str, size_t str_length); typedef struct { size_t (*cli_shell_write)(const char *str, size_t str_length); diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 27335a2..d67cefc 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -267,13 +267,9 @@ static inline int sapi_cli_select(php_socket_t fd) return ret != -1; } -PHP_CLI_API size_t sapi_cli_single_write(const char *str, size_t str_length) /* {{{ */ +PHP_CLI_API ssize_t sapi_cli_single_write(const char *str, size_t str_length) /* {{{ */ { -#ifdef PHP_WRITE_STDOUT - zend_long ret; -#else - size_t ret; -#endif + ssize_t ret; if (cli_shell_callbacks.cli_shell_write) { cli_shell_callbacks.cli_shell_write(str, str_length); @@ -283,16 +279,10 @@ PHP_CLI_API size_t sapi_cli_single_write(const char *str, size_t str_length) /* do { ret = write(STDOUT_FILENO, str, str_length); } while (ret <= 0 && errno == EAGAIN && sapi_cli_select(STDOUT_FILENO)); - - if (ret <= 0) { - return 0; - } - - return ret; #else ret = fwrite(str, 1, MIN(str_length, 16384), stdout); - return ret; #endif + return ret; } /* }}} */ @@ -300,7 +290,7 @@ static size_t sapi_cli_ub_write(const char *str, size_t str_length) /* {{{ */ { const char *ptr = str; size_t remaining = str_length; - size_t ret; + ssize_t ret; if (!str_length) { return 0; @@ -317,8 +307,9 @@ static size_t sapi_cli_ub_write(const char *str, size_t str_length) /* {{{ */ while (remaining > 0) { ret = sapi_cli_single_write(ptr, remaining); - if (!ret) { + if (ret < 0) { #ifndef PHP_CLI_WIN32_NO_CONSOLE + EG(exit_status) = 255; php_handle_aborted_connection(); #endif break;

« previous php.cvs (#102187) next »