# Problem in CLI

- Thread: https://externals.io/message/10078
- Original archive: https://news-web.php.net/php.internals/10078
- Started by Andi Gutmans on 2004-05-25T10:14:10+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #10078 — Andi Gutmans — 2004-05-25T10:14:10+00:00

URL: https://externals.io/message/10078#10078

The following script:
<?php
error_reporting(E_ALL);
leak(100);
print "hello\n";

Doesn't report a leak in CLI mode but it does in CGI. It seems that stderr 
and stdout file descriptors are getting screwed up in CLI. I remember 
someone messing around with this.
Any ideas?

Thanks,

Andi

---

## #10081 — Wez Furlong — 2004-05-25T11:21:38+00:00

URL: https://externals.io/message/10078#10081 · In reply to: #10078

When `STDERR` gets dtor'd, the descriptor is closed, so the leak messages are
heading into the void.

The reason for the change was so that PHP CLI could be launched from inetd and
be able to close descriptors.

A (somewhat hacky) fix would be to skip closing the descriptor if it is the
stderr descriptor and if PHP is in request shutdown.

--Wez.

> -----Original Message-----
> From: Andi Gutmans [mailto:andi@zend.com] 
> Sent: 25 May 2004 11:14
> To: internals@lists.php.net
> Subject: [PHP-DEV] Problem in CLI
> 
> The following script:
> <?php
> error_reporting(E_ALL);
> leak(100);
> print "hello\n";
> 
> Doesn't report a leak in CLI mode but it does in CGI. It 
> seems that stderr 
> and stdout file descriptors are getting screwed up in CLI. I remember 
> someone messing around with this.
> Any ideas?
> 
> Thanks,
> 
> Andi

---

## #10083 — Andi Gutmans — 2004-05-25T12:06:53+00:00

URL: https://externals.io/message/10078#10083 · In reply to: #10078

Why are we creating a resource for these descriptors? Is it for the 
constants in PHP?

Andi

At 12:21 PM 5/25/2004 +0100, Wez Furlong wrote:
>When `STDERR` gets dtor'd, the descriptor is closed, so the leak messages are
>heading into the void.
>
>The reason for the change was so that PHP CLI could be launched from inetd and
>be able to close descriptors.
>
>A (somewhat hacky) fix would be to skip closing the descriptor if it is the
>stderr descriptor and if PHP is in request shutdown.
>
>--Wez.
>
> > […]
