add background execution option/flag

This commit is contained in:
Dennis Eichhorn 2022-03-11 23:16:35 +01:00
parent 1d583a03ea
commit 3e609e6041

View File

@ -147,17 +147,25 @@ final class SystemUtils
return 'localhost.localdomain'; return 'localhost.localdomain';
} }
public static function runProc(string $executable, string $cmd) : array public static function runProc(string $executable, string $cmd, bool $async = false) : array
{ {
if (\strtolower((string) \substr(\PHP_OS, 0, 3)) === 'win') { if (\strtolower((string) \substr(\PHP_OS, 0, 3)) === 'win') {
$cmd = 'cd ' . \escapeshellarg(\dirname($executable)) $cmd = 'cd ' . \escapeshellarg(\dirname($executable))
. ' && ' . \basename($executable) . ' && ' . \basename($executable)
. ' ' . ' '
. $cmd; . $cmd;
if ($async) {
$cmd .= ' > nul 2>&1';
}
} else { } else {
$cmd = \escapeshellarg($executable) $cmd = \escapeshellarg($executable)
. ' ' . ' '
. $cmd; . $cmd;
if ($async) {
$cmd .= ' > /dev/null 2>&1';
}
} }
$pipes = []; $pipes = [];