|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26838 signals make STDIN become EOF
Submitted: 2004-01-08 05:50 UTC Modified: 2008-07-11 21:16 UTC
Avg. Score:3.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: xuefer at 21cn dot com Assigned:
Status: Wont fix Package: Filesystem function related
PHP Version: 4.3.4 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: xuefer at 21cn dot com
New email:
PHP Version: OS:


 [2004-01-08 05:50 UTC] xuefer at 21cn dot com
shell> ./test.php
don't press CTRL+D to end input. but program exists in 3 seconds because feof() return true
uncomment line 7 will works ok, exit only when i press CTRL+D

Reproduce code:
file ./test.php:

function sig_handler($signo) {
        global $stdin;
        print "Caught SIGALM...\n";
        // line7 // $stdin = fopen("php://stdin", 'r') or die('1');

print "Installing signal handler...\n";
pcntl_signal(SIGALRM, "sig_handler");
print "Generating signal SIGTERM to self...\n";

$stdin = fopen("php://stdin", 'r') or die('1');
while (!feof($stdin)) {
        echo fgets($stdin);

print "Done\n"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-08 20:35 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

signals can and will interrupt readings from files & 
 [2008-07-05 21:41 UTC] dazjorz at dazjorz dot com

Could you explain to me why this isn't a PHP bug? I don't observe this behavior in any other language.

Please see the IEEE standard for alarm() at They don't speak about any behavior that STDOUT should be eof'd.

I consider this a bug in PHP, even if it is documented. (I couldn't find any documentation, though.)


$ perl -le '$SIG{ALRM} = sub { print "Alarm called!"; alarm(5); }; alarm(5); print while(<>)'
 [2008-07-11 21:16 UTC]
We are sorry, but we can not support PHP 4 related problems anymore.
Momentum is gathering for PHP 6, and we think supporting PHP 4 will
lead to a waste of resources which we want to put into getting PHP 6

PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC