From fa1632f24a6fb6350644f13df4bf3d65e53fbfb5 Mon Sep 17 00:00:00 2001 From: Yurun Date: Thu, 30 Sep 2021 13:12:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=89=A7=E8=A1=8C=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E7=9A=84=E5=8F=82=E6=95=B0=E6=8B=BC=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Server/Cli/Server.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Server/Cli/Server.php b/src/Server/Cli/Server.php index 510ec9c..b20cee7 100644 --- a/src/Server/Cli/Server.php +++ b/src/Server/Cli/Server.php @@ -11,6 +11,7 @@ use Imi\Cli\Annotation\Option; use Imi\Cli\ArgType; use Imi\Cli\Contract\BaseCommand; +use function Imi\ttyExec; use Imi\Util\File; /** @@ -27,18 +28,10 @@ class Server extends BaseCommand */ public function start(string $host, int $port): void { - $cmd = '"' . \PHP_BINARY . '" -S ' . $host . ':' . $port . ' -t "' . File::path(App::get(AppContexts::APP_PATH), 'public') . '"'; - $descriptorspec = [ - ['pipe', 'r'], // 标准输入,子进程从此管道中读取数据 - ['pipe', 'w'], // 标准输出,子进程向此管道中写入数据 - ]; - $p = proc_open(\Imi\cmd($cmd), $descriptorspec, $pipes, null, null, [ - 'bypass_shell' => true, + ttyExec([ + \PHP_BINARY, + '-S', $host . ':' . $port, + '-t', File::path(App::get(AppContexts::APP_PATH), 'public'), ]); - while ($tmp = fgets($pipes[1])) - { - echo $tmp; - } - proc_close($p); } }