update runProcess to return process exit code

This commit is contained in:
Roman Kelesidis 2025-06-19 20:15:12 +03:00
commit c3182ae740
No known key found for this signature in database
GPG key ID: D8157C4D4C4C6DB4

View file

@ -86,9 +86,9 @@ function out(string $str, string $type = ''): void
* *
* @param string $cmd * @param string $cmd
* @param string|null $input * @param string|null $input
* @return void * @return int
*/ */
function runProcess(string $cmd, ?string $input = null): void function runProcess(string $cmd, ?string $input = null): int
{ {
$descriptorSpec = [ $descriptorSpec = [
0 => ['pipe', 'r'], 0 => ['pipe', 'r'],
@ -100,7 +100,7 @@ function runProcess(string $cmd, ?string $input = null): void
if (!is_resource($process)) { if (!is_resource($process)) {
out('- Could not start subprocess', 'error'); out('- Could not start subprocess', 'error');
return; return -1;
} }
// Write input if provided // Write input if provided
@ -124,7 +124,7 @@ function runProcess(string $cmd, ?string $input = null): void
fclose($pipes[1]); fclose($pipes[1]);
fclose($pipes[2]); fclose($pipes[2]);
proc_close($process); return proc_close($process);
} }
/** /**