Re: Dettach problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, June 13, 2006 4:22 am, grape wrote:
> 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;
> }
>
> 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...

This seems to me like a cogent bug report...
http://bugs.php.net/

But what does the posix_setsid() bit do?  Seems like you could take
that out too, no?...  Or does that "promote" the process to "be" the
parent somehow?...  Thereby confusing "fork" into thinking that it's
not the child process in some twisted weird way?  I read the docs ;
But comprehension is not implied. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux