|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66227 exec() returns early upon multiple signals
Submitted: 2013-12-03 18:12 UTC Modified: -
Avg. Score:3.5 ± 1.5
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: bhiggins at arbor dot net Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: 5.5Git-2013-12-03 (Git) OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-12-03 18:12 UTC] bhiggins at arbor dot net
The exec() routine fails to read its child process output, when the php program receives multiple signals - ie, SIGUSR1 is received in the apache process multiple times.

exec() calls php_stream_read_line(), which calls php_stream_fill_read_buffer(), which calls php_stdio_read().  php_stdio_read() attempts to read from the pipe to the child process, but only retries the read once when the read is interrupted.

I have encountered a scenario in which the second read is also interrupted.  When this happens, the error bubbles up the stack, ultimately resulting in errors in the child process (when it tries to write to its closed stdout pipe) and a failure of the exec() call to gather output from the child process.

I have a patch that retries the read indefinitely when it's interrupted.  This appears to fix the issue.

Test script:
No script.  Run php in apache, and exec() a child process that sleeps for 30 seconds.  Then, kill -USR1 <apache pid> multiple times.  The child process will fail to write to stdout, and the exec() call will not return the output from the child process.


php-read-retry.diff (last revision 2013-12-03 18:12 UTC by bhiggins at arbor dot net)

Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Feb 24 06:01:26 2020 UTC