ID:               32024
 User updated by:  davidcrawford at sympatico dot ca
 Reported By:      davidcrawford at sympatico dot ca
 Status:           Bogus
 Bug Type:         CGI related
 Operating System: FreeBSD4.10
 PHP Version:      5.0.3
 New Comment:

I re-compiled my PHP CGI/CLI with --enable-pcntl after reading up on
the PCNTL extension capabilities.

Thank you very much for pointing out the error in my method, I am glad
that this was not a PHP issue.


Previous Comments:
------------------------------------------------------------------------

[2005-02-18 20:17:18] [EMAIL PROTECTED]

For a process to detach from the shell, you need to fork off a child
and exit from the parent.


------------------------------------------------------------------------

[2005-02-18 20:10:07] davidcrawford at sympatico dot ca

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 this bug report at http://bugs.php.net/?id=32024&edit=1

Reply via email to