|  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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 14 15:01:28 2024 UTC