From 923c45bdcaebf317ce84a4bfb3fa39beae1bf952 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 31 May 2020 13:28:09 +0200 Subject: Fix #79650: php-win.exe 100% cpu lockup As of PHP 7.3.0, `sapi_cli_single_write()` is supposed to return `< 0` on failure, but `fwrite()` returns a `size_t`, and signals error by setting the stream's error indicator. We have to cater to that. --- sapi/cli/php_cli.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 342c5e5feb..2b6ace754c 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -279,6 +279,9 @@ PHP_CLI_API ssize_t sapi_cli_single_write(const char *str, size_t str_length) /* } while (ret <= 0 && errno == EAGAIN && sapi_cli_select(STDOUT_FILENO)); #else ret = fwrite(str, 1, MIN(str_length, 16384), stdout); + if (ret == 0 && ferror(stdout)) { + return -1; + } #endif return ret; } -- cgit v1.2.1