php.net |  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
Votes:2
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: xuefer at 21cn dot com
New email:
PHP Version: OS:

 

 [2004-01-08 05:50 UTC] xuefer at 21cn dot com
Description:
------------
code
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:

#!/usr/bin/php
<?php
function sig_handler($signo) {
        global $stdin;
        print "Caught SIGALM...\n";
        pcntl_alarm(3);
        // 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";

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

print "Done\n"
?>



Patches

Pull Requests

History

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

signals can and will interrupt readings from files & 
sockets. 
 [2008-07-05 21:41 UTC] dazjorz at dazjorz dot com
Hi iliaa@php.net,

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 http://www.opengroup.org/onlinepubs/000095399/functions/alarm.html. 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.)

Sjors

$ perl -le '$SIG{ALRM} = sub { print "Alarm called!"; alarm(5); }; alarm(5); print while(<>)'
 [2008-07-11 21:16 UTC] jani@php.net
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
ready.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC