mirror of https://github.com/winsw/winsw
Console isolation
parent
b0423e3156
commit
7e644f7944
|
@ -8,6 +8,9 @@ namespace WinSW.Native
|
|||
{
|
||||
internal const int ATTACH_PARENT_PROCESS = -1;
|
||||
|
||||
[DllImport(Libraries.Kernel32, SetLastError = true)]
|
||||
internal static extern bool AllocConsole();
|
||||
|
||||
[DllImport(Libraries.Kernel32, SetLastError = true)]
|
||||
internal static extern bool AttachConsole(int processId);
|
||||
|
||||
|
|
|
@ -255,6 +255,9 @@ namespace WinSW
|
|||
|
||||
private void DoStart()
|
||||
{
|
||||
bool succeeded = ConsoleApis.FreeConsole();
|
||||
Debug.Assert(succeeded);
|
||||
|
||||
this.HandleFileCopies();
|
||||
|
||||
// handle downloads
|
||||
|
@ -551,7 +554,19 @@ namespace WinSW
|
|||
}
|
||||
}
|
||||
|
||||
Process process = Process.Start(startInfo);
|
||||
bool succeeded = ConsoleApis.AllocConsole();
|
||||
Debug.Assert(succeeded);
|
||||
|
||||
Process process;
|
||||
try
|
||||
{
|
||||
process = Process.Start(startInfo);
|
||||
}
|
||||
finally
|
||||
{
|
||||
succeeded = ConsoleApis.FreeConsole();
|
||||
Debug.Assert(succeeded);
|
||||
}
|
||||
|
||||
Log.Info($"Started process {process.Format()}.");
|
||||
|
||||
|
|
Loading…
Reference in New Issue