Re: Dettach problem
| From: | grape | Date: | Wed, 14 Jun 2006 07:38:25 +0000 |
| Subject: | Re: Dettach problem | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-237955@lists.php.net to get a copy of this message | ||
Hello,
Jochem Maas skrev:
pure guess work coming up... grape wrote:In fact, I tried a *lot* of variations of this code without success.Hi all, I would like run a php-script via CLI which outputs some information to stdout, and then go into background. I use code similar to this to fork and to dettach the child I/O from the TTY (some error handling removed to improve readability) <? echo "Hello from parent\n"; if(pcntl_fork()) { exit; } posix_setsid(); fclose( STDIN ); fclose( STDOUT ); fclose( STDERR ); if(pcntl_fork()) { exit; }what happens if you move the fclose() statements after this if() statement? I get the same result.
is STDIN et al actually defined? they should be - but we all theory and practice often live on different planets :-) That is very true :-) Yup, the're "resource(1) of type (stream)" alright.
are you using the same sapi in both version (i.e. are you maybe using CGI now iso CLI?) I'm using CLI in both environments.
echo "This message should NOT go to stdout of parent process\n"; ?> It works fine using PHP version 5.0.4, but when using PHP version 5.1.2 the output of the child ("This message....") goes to stdout of the parent process. So if I do: php test.php >output Using PHP 5.1.2, the file contains: --------------- Hello from parent This message should NOT go to stdout of parent process --------------- Can anybody explain this? I run FreeBSD 6.0-RELEASE... Regards, Grape /Grape