on php5.0.0,

I would like to have php core team opinion on this :
- cli version loose stdin when using pcntl_signal,  but it's NOT possible to
recover it
- cgi version loose stdin when using pcntl_signal,  and it's possible to
recover it

If it's not a bug, i just would like to understand ;)


Little test script :

<?php

// Use this little test script like that :
// while :; do date; sleep 1; done | php ./test2.php

function sig_handler($signo) {
        global $stdin;
        print "Caught SIGALM...\n";
        pcntl_alarm(3);

// For explain line below, see http://bugs.php.net/bug.php?id=26838
// "signals make STDIN become EOF"

        $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"




/*

// Using PHP-5.0.0(cgi) --enable-cgi --enable-fastcgi, $stdin is recover
when sig_handler called

// WORK

Output:

<[EMAIL PROTECTED]> while :; do date; sleep 1; done | php-cgi ./test2.php
Content-type: text/html; charset=UTF-8

Installing signal handler...
Generating signal SIGTERM to self...
lun jui 19 16:23:38 CEST 2004
lun jui 19 16:23:39 CEST 2004
lun jui 19 16:23:40 CEST 2004
lun jui 19 16:23:41 CEST 2004
Caught SIGALM...
lun jui 19 16:23:42 CEST 2004 // !feof stdin, continu while() ;)
lun jui 19 16:23:44 CEST 2004
....
....


// Using PHP-5.0.0(cli) --disable-cgi --disable-fastcgi, $stdin is NOT
recover when sig_handler called

// --> ERROR ?

Output :

<[EMAIL PROTECTED]> while :; do date; sleep 1; done | php-cli ./test2.php
Installing signal handler...
Generating signal SIGTERM to self...
lun jui 19 16:23:26 CEST 2004
lun jui 19 16:23:27 CEST 2004
lun jui 19 16:23:28 CEST 2004
lun jui 19 16:23:29 CEST 2004
Caught SIGALM...
Done // feof stdin --> end of program

*/
?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to