Bug #66227 [NEW]: exec() returns early upon multiple signals
| From: | bhiggins at arbor dot net | Date: | Tue, 03 Dec 2013 18:12:08 +0000 |
| Subject: | Bug #66227 [NEW]: exec() returns early upon multiple signals | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-183111@lists.php.net to get a copy of this message | ||
From: bhiggins at arbor dot net
Operating system: Linux
PHP version: 5.5Git-2013-12-03 (Git)
Package: Scripting Engine problem
Bug Type: Bug
Bug description:exec() returns early upon multiple signals
Description:
------------
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.
--
Edit bug report at https://bugs.php.net/bug.php?id=66227&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66227&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66227&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66227&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66227&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66227&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66227&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66227&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66227&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66227&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66227&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66227&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66227&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66227&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66227&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66227&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66227&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66227&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66227&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66227&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66227&r=mysqlcfg