Skip to content

Close-GH 15685: improve proc_open error reporting on Windows #15687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ext/standard/proc_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,9 @@ PHP_FUNCTION(proc_open)
if (newprocok == FALSE) {
DWORD dw = GetLastError();
close_all_descriptors(descriptors, ndesc);
php_error_docref(NULL, E_WARNING, "CreateProcess failed, error code: %u", dw);
char *msg = php_win32_error_to_msg(dw);
php_error_docref(NULL, E_WARNING, "CreateProcess failed: %s", msg);
php_win32_error_msg_free(msg);
goto exit_fail;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ operable program or batch file.
'"%sghsa-9fcc-425m-g385_001.bat. ... . ."' is not recognized as an internal or external command,
operable program or batch file.

Warning: proc_open(): CreateProcess failed, error code: 2 in %s on line %d
Warning: proc_open(): CreateProcess failed: The system cannot find the file specified in %s on line %d
--CLEAN--
<?php
@unlink(__DIR__ . '/ghsa-9fcc-425m-g385_001.bat');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ $proc = proc_open(["\\cmd. ... ", "/c", $batch_file_path, "\"&notepad.exe"], $d
%sghsa-9fcc-425m-g385_002.bat
"&notepad.exe

Warning: proc_open(): CreateProcess failed, error code: 2 in %s on line %d
Warning: proc_open(): CreateProcess failed: The system cannot find the file specified in %s on line %d
%sghsa-9fcc-425m-g385_002.bat
"&notepad.exe
%sghsa-9fcc-425m-g385_002.bat
"&notepad.exe

Warning: proc_open(): CreateProcess failed, error code: 2 in %s on line %d
Warning: proc_open(): CreateProcess failed: The system cannot find the file specified in %s on line %d

Warning: proc_open(): CreateProcess failed, error code: 2 in %s on line %d
Warning: proc_open(): CreateProcess failed: The system cannot find the file specified in %s on line %d

Warning: proc_open(): CreateProcess failed, error code: 2 in %s on line %d
Warning: proc_open(): CreateProcess failed: The system cannot find the file specified in %s on line %d
--CLEAN--
<?php
@unlink(__DIR__ . '/ghsa-9fcc-425m-g385_002.bat');
Expand Down
Loading