|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-06-29 20:57 UTC] cmb@php.net
[2015-06-29 21:17 UTC] poonam dot chawla at mathworks dot com
[2015-06-30 09:25 UTC] ab@php.net
-Assigned To:
+Assigned To: ab
[2015-06-30 11:30 UTC] ab@php.net
[2015-06-30 13:27 UTC] poonam dot chawla at mathworks dot com
[2015-07-01 14:58 UTC] ab@php.net
-Status: Assigned
+Status: Feedback
[2015-07-01 14:58 UTC] ab@php.net
[2015-07-02 20:19 UTC] ab@php.net
[2015-07-02 20:21 UTC] poonam dot chawla at mathworks dot com
-Status: Feedback
+Status: Assigned
[2015-07-02 20:21 UTC] poonam dot chawla at mathworks dot com
[2015-07-07 13:40 UTC] ab@php.net
-Status: Assigned
+Status: Closed
[2015-07-07 13:40 UTC] ab@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 16 06:00:02 2025 UTC |
Description: ------------ I am using PHP to read from STDIN and write to a log file. The PHP process is spawned by another process (for the example sake, I am attaching a python script that spawns a new PHP process). I observed that if there is nothing to read on the STDIN for a short period of time, PHP behaves unexpectedly (reads EOF and exits).It was interesting to find out that PHP 5.4 exhibhits the correct behavior, however both PHP 5.5 and 5.6 behave unexpectedly. Test script: --------------- PHP: <?php $in = fopen("php://stdin", "rb"); $out = fopen('C:/Users/pchawla/php_test/log_file.txt', 'w'); while ( ! feof($in) ) { $line = fgets($in); fwrite($out, $line); } ?> import subprocess import sys Python: import subprocess import sys def log(): proc = subprocess.Popen(['php', 'C:/Users/pchawla/php_test/log_handler.php'], stdin=subprocess.PIPE) while True: line = sys.stdin.readline(); proc.stdin.write(line) if __name__ == "__main__": log() Expected result: ---------------- fgets() should return FALSE only when there is an error or it reads EOF from the PIPE. Actual result: -------------- fgets() returns FALSE when there is nothing to read from the PIPE for a short period of time (~20 seconds).