This is a funny one. The issue occurs on a Linux server running Remi el8 PHP 8.1, but not on another Linux server running Remi el7 PHP 8.1
When I do an 'arc land' it errors with:
EXCEPTION: (CommandException) Command failed with error #-1! COMMAND php -d variables_order=E -r 'echo json_encode($_ENV);' STDOUT {MyEnvironmentVars} STDERR (empty) at [<arcanist>/src/future/exec/ExecFuture.php:436] arcanist(head=master, ref.master=788098096e11) #0 ExecFuture::raiseResultError(array) called at [<arcanist>/src/future/exec/ExecFuture.php:340] #1 ExecFuture::resolvex() called at [<arcanist>/src/future/exec/execx.php:17] #2 execx(string, string) called at [<arcanist>/src/utils/PhutilExecutionEnvironment.php:40] #3 PhutilExecutionEnvironment::repairMissingVariablesOrder() called at [<arcanist>/support/init/init-script.php:120] #4 __arcanist_init_script__() called at [<arcanist>/support/init/init-script.php:131] #5 require_once(string) called at [<arcanist>/support/init/init-arcanist.php:3] #6 require_once(string) called at [<arcanist>/bin/arc:10]
Debugging showed that every call to proc_get_status() in ExecFuture.php returned an exitcode of -1, before and after the process completing.
My workaround kludge is to assume assume nothing really returns -1:
diff --git a/src/future/exec/ExecFuture.php b/src/future/exec/ExecFuture.php index ddf9e515..31d4c90f 100644 --- a/src/future/exec/ExecFuture.php +++ b/src/future/exec/ExecFuture.php @@ -932,6 +932,8 @@ final class ExecFuture extends PhutilExecutableFuture { } $this->procStatus = proc_get_status($this->proc); + if ($this->procStatus['exitcode'] == -1) + $this->procStatus['exitcode'] = 0; return $this->procStatus;
Trying to replicate the issue outside of arcanist fails. The following ends with an exitcode 0 as expected:
#!/usr/bin/env php <?php $descriptorspec = [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']]; //STDIN, STDOUT, STDERR $proc = proc_open("php -d variables_order=E -r 'echo json_encode(\$_ENV);'", $descriptorspec, $pipes); do { $status = proc_get_status($proc); echo var_export($status, true), "\n"; if (! $status['running']) break; } while (true);
Which means it's probably something in the guts of PHP related to the specific server build. Thought I'd put it out here to see if anyone else experienced it.