[php-src] PR #22311: Fix file descriptor leak when proc_open() descriptor setup fails
| From: | iliaal | Date: | Sun, 14 Jun 2026 17:19:34 +0000 |
| Subject: | [php-src] PR #22311: Fix file descriptor leak when proc_open() descriptor setup fails | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36426@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22311
Author: iliaal
When a descriptor spec entry fails to set up (unknown type, missing mode) after an earlier entry
already opened a pipe or socket, proc_open() jumped to exit_fail without closing the descriptors it
had already opened. The fds leak and repeated calls exhaust the process descriptor table;
close_all_descriptors() ran only when the spawn itself failed. Close them at exit_fail and drop the
now-redundant per-call close before each spawn-failure goto.
```php
for ($i = 0; $i < 200; $i++) {
@proc_open('true', [0 => ['pipe', 'r'], 1 =>
['bogus']], $pipes);
}
// 400 fds leaked before the patch (2 per call)
```