Skip to content

Commit

Permalink
Redirection of standard input as well as closing it
Browse files Browse the repository at this point in the history
causes the process to end normally when it is waiting for input
  • Loading branch information
SeidChr committed Nov 17, 2018
1 parent c647157 commit b594c6c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ public static int Main(string[] args)

var startInfo = new ProcessStartInfo
{
////CreateNoWindow = true,
////UseShellExecute = false,
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardInput = true,
WindowStyle = ProcessWindowStyle.Hidden,
WorkingDirectory = Directory.GetCurrentDirectory(),
Arguments = string.Join(" ", args),
Expand All @@ -49,11 +50,10 @@ public static int Main(string[] args)
return -7002;
}

if (!proc.WaitForExit(60000))
{
SimpleLog.Error("Process didn't close within 60s. Killing.");
proc.Kill();
}
// process will close as soon as its waiting for interactive input.
proc.StandardInput.Close();

proc.WaitForExit();

return proc.ExitCode;
}
Expand Down

0 comments on commit b594c6c

Please sign in to comment.