Re: Disable STDOUT
| From: | Patrick O'Lone | Date: | Mon, 08 Jul 2002 05:35:23 +0000 |
| Subject: | Re: Disable STDOUT | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-85828@lists.php.net to get a copy of this message | ||
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" <polone@townnews.com> wrote in message
news:20020708052214.279.qmail@pb1.pair.com...
> 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);
>
> }
> /* }}} */
>
>