Skip to content

Commit 1111a95

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. Closes GH-11510.
1 parent 4d91665 commit 1111a95

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.1.22
44

5+
- CLI:
6+
. Fix interrupted CLI output causing the process to exit. (nielsdos)
7+
58
- Date:
69
. Fixed bug GH-11368 (Date modify returns invalid datetime). (Derick)
710

sapi/cli/php_cli.c

Lines changed: 1 addition & 1 deletion
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)