From:             davidcrawford at sympatico dot ca
Operating system: FreeBSD4.10
PHP version:      5.0.3
PHP Bug Type:     CGI related
Bug description:  fclose(STDIN|STDOUT|STDERR) has no effect

Description:
------------
I am trying to run a simple PHP script in the background (as a daemon)
using the PHP 5 CLI. I first set the execution time limit to 0 (no limit),
and then I attempt to close STDIN, STDOUT, STDERR using fclose(), but the
pipes are _NOT_ being closed.

This problem seems quite similar to bug #27865, which is labelled as
"fixed", but the behaviour I am getting in this instance is not as
documented.

Reproduce code:
---------------
set_time_limit(0);
        
fclose(STDIN);
fclose(STDOUT);
fclose(STDERR);

sleep(...sync timing with system clock...);

while (TRUE) {
   system(...generate call...);
   sleep(...sleep some more...);
} // END while

Expected result:
----------------
After invocation from the command line, the program should close all STD
pipes, and run in the background. A new prompt should appear in the shell,
ready to accept my next command while the PHP script is running in the
background without open pipes to my current terminal.

Actual result:
--------------
A new command prompt does not appear, instead the terminal hangs in
suspense waiting for the process to complete. The script is designed to
run forever in a tight loop. Hitting Ctrl+C gets the command prompt back,
but interrupts and kills the PHP process.

I can get the desired result by using I/O tricks from the command line:

./script.php &

But, this solution has limitations.

-- 
Edit bug report at http://bugs.php.net/?id=32024&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32024&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32024&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32024&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32024&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32024&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32024&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32024&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32024&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32024&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32024&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=32024&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=32024&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32024&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32024&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32024&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32024&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32024&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32024&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32024&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32024&r=mysqlcfg

Reply via email to