From 3e609e604163ff0fd94d595f1df474607612842d Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 11 Mar 2022 23:16:35 +0100 Subject: [PATCH] add background execution option/flag --- System/SystemUtils.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/System/SystemUtils.php b/System/SystemUtils.php index be470ee6e..1a0398e86 100644 --- a/System/SystemUtils.php +++ b/System/SystemUtils.php @@ -147,17 +147,25 @@ final class SystemUtils 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') { $cmd = 'cd ' . \escapeshellarg(\dirname($executable)) . ' && ' . \basename($executable) . ' ' . $cmd; + + if ($async) { + $cmd .= ' > nul 2>&1'; + } } else { $cmd = \escapeshellarg($executable) . ' ' . $cmd; + + if ($async) { + $cmd .= ' > /dev/null 2>&1'; + } } $pipes = [];