From ac4256aedf2b65e121f6c7d816785ce8a1c4e937 Mon Sep 17 00:00:00 2001 From: Zaitonn <103164490+Zaitonn@users.noreply.github.com> Date: Mon, 30 Dec 2024 10:52:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=B3=E6=9C=8D=E6=97=B6=E5=B4=A9?= =?UTF-8?q?=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Serein.Core/Services/Servers/ServerWithPty.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Serein.Core/Services/Servers/ServerWithPty.cs b/src/Serein.Core/Services/Servers/ServerWithPty.cs index a2e8549c..b59b336f 100644 --- a/src/Serein.Core/Services/Servers/ServerWithPty.cs +++ b/src/Serein.Core/Services/Servers/ServerWithPty.cs @@ -105,8 +105,8 @@ protected override void StartProcess() _ptyConnection.Dispose(); _ptyConnection = null; _process = null; - _streamReader?.Close(); OnServerExit(e.ExitCode); + _streamReader?.Close(); _cancellationTokenSource.Cancel(); }; _streamReader = new( @@ -137,10 +137,19 @@ private async Task ReadLineLoop() OnServerOutput(line); } } + catch (ObjectDisposedException) + { + break; + } catch (OperationCanceledException) { break; } + catch (Exception e) + { + WriteErrorLine(e.Message); + _logger.LogDebug(e, "读取服务器输出时发生错误"); + } } _streamReader?.Dispose();