|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-12-04 05:14 UTC] php-bugs at jbeekman dot nl
Description: ------------ When a program executed with proc_open closes an output pipe, PHP sometimes incorrectly reports that the stream has not reached EOF and at other times it's stuck in a blocking read. Attached are 5 test programs and a test script: * The closewait program is a test program that writes a specified number of bytes to STDOUT, closes STDOUT, and sleeps for a specified time. * The fifotest* programs are used to test the operation of named pipes (FIFOs). The C and PHP version are very similar. just opening a specified file and reading from it in 64-byte chunks until error/EOF. * The pipetest* programs are used to test the operation of unnamed pipes (pipes). The C version uses pipe() to create the pipe and fork() to give one end to a child process. The PHP version uses proc_open() to do the same. Both programs use the same logic as the fifotest* programs to read from the pipe. * The test.sh script compiles the C programs and runs the C and PHP programs with different parameters. From the tests, you can see that the FIFOs work the same in both C and PHP, but that the pipe has some erratic behavior. In one case it exits after reading all the data from the pipe, but does not indicate EOF. In two other cases it blocks after reading all the data from the pipe until the child process exits. From `man 7 pipe': "[I/O on pipes and FIFOs] The only difference between pipes and FIFOs is the manner in which they are created and opened. Once these tasks have been accomplished, I/O on pipes and FIFOs has exactly the same semantics." There is no posix_pipe() (see bug #60896), so I can't test whether there is an issue with pipes in general or just with proc_open(). Test script: --------------- git commit 00a7b1ff (branch PHP-5.5 as of 2013-12-3 16:36:07 PST) Configure Command: './configure' '--disable-all' '--disable-cgi' '--enable-cli' Download all of the following and save them under the specified name in the same folder and then: chmod ugo+x test.sh; ./test.sh ** unable to post links because of bugs.php.net spam detection ** Expected result: ---------------- ===>FIFO test (C) n: 63 EOF: 1 n: 64 n: 0 EOF: 1 n: 64 n: 1 EOF: 1 ===>FIFO test (PHP) n: 63 EOF: 1 n: 64 n: 0 EOF: 1 n: 64 n: 1 EOF: 1 ===>pipe test (C) n: 63 EOF: 1 n: 64 n: 0 EOF: 1 n: 64 n: 1 EOF: 1 ===>pipe test (PHP) n: 63 EOF: 1 n: 64 n: 0 EOF: 1 n: 64 n: 1 EOF: 1 real less than 1 user irrelevant sys irrelevant Actual result: -------------- ===>FIFO test (C) n: 63 EOF: 1 n: 64 n: 0 EOF: 1 n: 64 n: 1 EOF: 1 ===>FIFO test (PHP) n: 63 EOF: 1 n: 64 n: 0 EOF: 1 n: 64 n: 1 EOF: 1 ===>pipe test (C) n: 63 EOF: 1 n: 64 n: 0 EOF: 1 n: 64 n: 1 EOF: 1 ===>pipe test (PHP) n: 63 EOF: 0 n: 64 n: 0 EOF: 1 n: 64 n: 1 EOF: 1 real 2.13 user 0.04 sys 0.06 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 13:00:01 2025 UTC |
Here are the test files that the bug tracker would not let me post in the description ("Please do not SPAM our bug system."). You will have to insert :// in the appropriate places. Download all of the following and save them under the specified name in the same folder and then: chmod ugo+x test.sh; ./test.sh closewait.c http pastebin.com/utgrkXJM fifotest.c http pastebin.com/p8R3WsEk fifotest.php http pastebin.com/bJgCcjpF pipetest.c http pastebin.com/9Wd2QSLD pipetest.php http pastebin.com/qRwuZsnx test.sh http pastebin.com/J8TmXYAG