[php-src] Issue #12589: proc_open() fails for non-existent commands with error: posix_spawn() failed

From: Date: Wed, 01 Nov 2023 18:06:32 +0000
Subject: [php-src] Issue #12589: proc_open() fails for non-existent commands with error: posix_spawn() failed
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245715@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12589 Author: ausi ### Description Since https://github.com/php/php-src/pull/7933 there is a change in how proc_open() handles non-existent commands. The following code: ```php <?php var_dump($p = proc_open(["invalid_command"], [], $pipes)); var_dump(proc_close($p)); ``` Resulted in this output: ``` PHP Warning: proc_open(): posix_spawn() failed: No such file or directory in Command line code on line 1 bool(false) PHP Fatal error: Uncaught TypeError: proc_close(): Argument #1 ($process) must be of type resource, false given in Command line code:1 ``` But I expected this output instead (as it was before PHP 8.3): ``` resource(4) of type (process) PHP Warning: proc_open(): Exec failed: No such file or directory in Command line code on line 1 int(127) ``` The different behavior only occurs when passing the command as an array, passing it as a string still behaves as it always did: ```php <?php var_dump($p = proc_open("invalid_command", [], $pipes)); var_dump(proc_close($p)); ``` Results in this output for all PHP Versions: ``` resource(4) of type (process) sh: invalid_command: command not found int(127) ``` As calling non-existent commands is probably pretty common, I think the old behavior of returning exit code 127 should be restored for that case. ### PHP Version PHP 8.3.0RC5 ### Operating System macOS 13.6 (22G120)

« previous php.bugs (#245715) next »