Skip to content

Commit

Permalink
Fix interrupted CLI output causing the process to exit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nielsdos committed Jun 23, 2023
1 parent 4d91665 commit 1111a95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS
Expand Up @@ -2,6 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.1.22

- CLI:
. Fix interrupted CLI output causing the process to exit. (nielsdos)

- Date:
. Fixed bug GH-11368 (Date modify returns invalid datetime). (Derick)

Expand Down
2 changes: 1 addition & 1 deletion sapi/cli/php_cli.c
Expand Up @@ -262,7 +262,7 @@ PHP_CLI_API ssize_t sapi_cli_single_write(const char *str, size_t str_length) /*
#ifdef PHP_WRITE_STDOUT
do {
ret = write(STDOUT_FILENO, str, str_length);
} while (ret <= 0 && errno == EAGAIN && sapi_cli_select(STDOUT_FILENO));
} while (ret <= 0 && (errno == EINTR || (errno == EAGAIN && sapi_cli_select(STDOUT_FILENO))));
#else
ret = fwrite(str, 1, MIN(str_length, 16384), stdout);
if (ret == 0 && ferror(stdout)) {
Expand Down

0 comments on commit 1111a95

Please sign in to comment.