#26838 [Opn->WFx]: signals make STDIN become EOF

From: Date: Fri, 11 Jul 2008 21:16:04 +0000
Subject: #26838 [Opn->WFx]: signals make STDIN become EOF
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-126524@lists.php.net to get a copy of this message
ID: 26838 Updated by: jani@php.net Reported By: xuefer at 21cn dot com -Status: Open +Status: Wont fix Bug Type: Filesystem function related Operating System: linux PHP Version: 4.3.4 New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2008-07-05 21:41:44] 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-05 21:34:18] colder@php.net reopening on user request ------------------------------------------------------------------------ [2004-01-08 20:35:02] 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. ------------------------------------------------------------------------ [2004-01-08 05:50:30] 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" ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26838&edit=1

« previous php.bugs (#126524) next »