[PHP-DEV] Re: Disable STDOUT

2002-07-07 Thread Patrick O'Lone

Maybe I should write a function disable all open file descriptors instead,
since traditionally that's how it is done. However, I thought PHP closes
STDIN after it's initial read - but I might be wrong.


"Patrick O'Lone" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hey PHP developers!
>
> I wrote function to disable STDOUT from the PHP binary. It just sets the
> php_output_set_status() flag option to disable output. However, I don't
know
> if PHP continues to buffer the output somewhere. Does anyone know? BTW -
> I've written this function because I want to write a daemon using PHP, but
> initiating a fork'd process from a TTY still causes PHP to deliver output
to
> the STDOUT. It's true, I could be more "unix-y" about the situation and
do:
> "php script.php &>/dev/null", but I'd rather be lazy and just type "php
> script.php" and let it daemonize properly. In addition, I know think this
> disassociates the TTY from STDERR - so runtime errors may still be
> generated.
>
>
> PHP_FUNCTION(ob_disable_stdout)
> {
>zval **zv_flag;
>int flag;
>
>switch(ZEND_NUM_ARGS()) {
>
>case 0:
> flag = 0;
> break;
>
>case 1:
> if (zend_get_parameters_ex(1, &zv_flag) == FAILURE) {
>RETURN_FALSE;
> }
> convert_to_long_ex(zv_flag);
> flag = Z_LVAL_PP(zv_flag);
> break;
>
>default:
> WRONG_PARAM_COUNT;
> break;
>
> }
>
> php_output_set_status(flag);
>
> }
> /* }}} */
>
>



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




Re: [PHP-DEV] Re: Disable STDOUT

2002-07-08 Thread David Eriksson

On Mon, 8 Jul 2002, Patrick O'Lone wrote:

> Maybe I should write a function disable all open file descriptors instead,
> since traditionally that's how it is done. However, I thought PHP closes
> STDIN after it's initial read - but I might be wrong.

I'd say that stdin, stdout and stderr are not simply closed but redirected
to /dev/null when writing a daemon. See the daemon() function in 4.4BSD.

Regards,

-\- David Eriksson -/-

"I personally refuse to use inferior tools because of ideology."
- Linus Torvalds 



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