From 163c828fbcd9b033b8b0f70d2f782c708269455b Mon Sep 17 00:00:00 2001 From: MaxXor Date: Wed, 27 May 2015 23:10:40 +0200 Subject: [PATCH] Fixed Shell cmd.exe process not correctly exited #232 --- Client/Core/RemoteShell/Shell.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Client/Core/RemoteShell/Shell.cs b/Client/Core/RemoteShell/Shell.cs index 9a69a2d6..c05c26fc 100644 --- a/Client/Core/RemoteShell/Shell.cs +++ b/Client/Core/RemoteShell/Shell.cs @@ -90,7 +90,8 @@ private void RedirectStandardOutput() if (!string.IsNullOrEmpty(read)) { Thread.Sleep(200); - new Packets.ClientPackets.ShellCommandResponse(read + Environment.NewLine).Execute(Program.ConnectClient); + new Packets.ClientPackets.ShellCommandResponse(read + Environment.NewLine).Execute( + Program.ConnectClient); } redirectOutputEvent.Reset(); @@ -100,6 +101,10 @@ private void RedirectStandardOutput() if ((_prc == null || _prc.HasExited) && _read) throw new ApplicationException("session unexpectedly closed"); } + catch (ObjectDisposedException ex) + { + // just exit + } catch (Exception ex) { if (ex is ApplicationException || ex is InvalidOperationException) @@ -132,7 +137,8 @@ private void RedirectStandardError() if (!string.IsNullOrEmpty(read)) { Thread.Sleep(200); - new Packets.ClientPackets.ShellCommandResponse(read + Environment.NewLine, true).Execute(Program.ConnectClient); + new Packets.ClientPackets.ShellCommandResponse(read + Environment.NewLine, true).Execute( + Program.ConnectClient); } redirectStandardErrorEvent.Set(); @@ -142,6 +148,10 @@ private void RedirectStandardError() if ((_prc == null || _prc.HasExited) && _read) throw new ApplicationException("session unexpectedly closed"); } + catch (ObjectDisposedException) + { + // just exit + } catch (Exception ex) { if (ex is ApplicationException || ex is InvalidOperationException)