Skip to content

Fix proc_open() null descriptor not inheritable on Windows - #24335

Open
jorgsowa wants to merge 1 commit into
php:PHP-8.4from
jorgsowa:fix-proc-open-null-inherit
Open

jorgsowa wants to merge 1 commit into
php:PHP-8.4from
jorgsowa:fix-proc-open-null-inherit

Conversation

@jorgsowa

@jorgsowa jorgsowa commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

On Windows, proc_open() with a ['null'] descriptor opens nul via CreateFileA() with NULL security attributes. The handle is therefore not inheritable, yet it is passed to CreateProcessW() through STARTF_USESTDHANDLES. The child gets an invalid std handle.

The pipe handles already use php_proc_open_security. This change uses it for nul too, so the handle is inherited.

This has been wrong since the null descriptor was added (6285bb52faf), but it only showed up once proc_open_null.phpt and proc_open_redirect.phpt started running the child php with TEST_PHP_EXTRA_ARGS (GH-11669).

Fixes failing CI.

The nul handle was opened without security attributes, making it
non-inheritable. It was then passed to CreateProcess() via
STARTF_USESTDHANDLES, where the child cannot use a non-inheritable
handle. Use php_proc_open_security so the handle is inheritable, like
the pipe handles.
@jorgsowa
jorgsowa marked this pull request as ready for review October 14, 2026 21:48
@jorgsowa
jorgsowa requested a review from bukka as a code owner October 14, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant