Skip to content

Commit 7cdea35

Browse files
committed
Fix interrupted CLI output causing the process to exit
When writing the output in the CLI is interrupted by a signal, the writing will fail in sapi_cli_single_write(), causing an exit later in sapi_cli_ub_write(). This was the other part of the issue in GH-11498. The solution is to restart the write if an EINTR has been observed.
1 parent 039dd0b commit 7cdea35

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sapi/cli/php_cli.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ PHP_CLI_API ssize_t sapi_cli_single_write(const char *str, size_t str_length) /*
262262
#ifdef PHP_WRITE_STDOUT
263263
do {
264264
ret = write(STDOUT_FILENO, str, str_length);
265-
} while (ret <= 0 && errno == EAGAIN && sapi_cli_select(STDOUT_FILENO));
265+
} while (ret <= 0 && (errno == EINTR || (errno == EAGAIN && sapi_cli_select(STDOUT_FILENO))));
266266
#else
267267
ret = fwrite(str, 1, MIN(str_length, 16384), stdout);
268268
if (ret == 0 && ferror(stdout)) {

0 commit comments

Comments
 (0)