Fixed Shell cmd.exe process not correctly exited

#232
This commit is contained in:
MaxXor 2015-05-27 23:10:40 +02:00
parent d53430d790
commit 163c828fbc
1 changed files with 12 additions and 2 deletions

View File

@ -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)