Leave STDIN open (#738)

pull/747/head
Next Turn 2020-12-09 01:39:37 +08:00 committed by GitHub
parent 16bbefdaae
commit 8cc17b5aa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 9 deletions

View File

@ -185,7 +185,6 @@ namespace WinSW.Util
/// <param name="workingDirectory">Working directory</param>
/// <param name="priority">Priority</param>
/// <param name="callback">Completion callback. If null, the completion won't be monitored</param>
/// <param name="redirectStdin">Redirect standard input</param>
/// <param name="logHandler">Log handler. If enabled, logs will be redirected to the process and then reported</param>
public static void StartProcessAndCallbackForExit(
Process processToStart,
@ -195,7 +194,6 @@ namespace WinSW.Util
string? workingDirectory = null,
ProcessPriorityClass? priority = null,
ProcessCompletionCallback? callback = null,
bool redirectStdin = true,
LogHandler? logHandler = null,
bool hideWindow = false)
{
@ -205,7 +203,6 @@ namespace WinSW.Util
ps.WorkingDirectory = workingDirectory ?? ps.WorkingDirectory;
ps.CreateNoWindow = hideWindow;
ps.UseShellExecute = false;
ps.RedirectStandardInput = redirectStdin;
ps.RedirectStandardOutput = logHandler?.OutFileDisabled == false;
ps.RedirectStandardError = logHandler?.ErrFileDisabled == false;

View File

@ -330,10 +330,8 @@ namespace WinSW
this.ExtensionManager.FireOnWrapperStarted();
var executableLogHandler = this.CreateExecutableLogHandler();
this.StartProcess(this.process, startArguments, this.descriptor.Executable, executableLogHandler, true);
this.StartProcess(this.process, startArguments, this.descriptor.Executable, executableLogHandler);
this.ExtensionManager.FireOnProcessStarted(this.process);
this.process.StandardInput.Close(); // nothing for you to read!
}
/// <summary>
@ -371,7 +369,7 @@ namespace WinSW
executable ??= this.descriptor.Executable;
// TODO: Redirect logging to Log4Net once https://github.com/kohsuke/winsw/pull/213 is integrated
this.StartProcess(stopProcess, stopArguments, executable, null, false);
this.StartProcess(stopProcess, stopArguments, executable, null);
Log.Debug("WaitForProcessToExit " + this.process.Id + "+" + stopProcess.Id);
this.WaitForProcessToExit(this.process);
@ -449,7 +447,7 @@ namespace WinSW
ServiceApis.SetServiceStatus(handle, this.wrapperServiceStatus);
}
private void StartProcess(Process processToStart, string arguments, string executable, LogHandler? logHandler, bool redirectStdin)
private void StartProcess(Process processToStart, string arguments, string executable, LogHandler? logHandler)
{
// Define handler of the completed process
void OnProcessCompleted(Process proc)
@ -496,7 +494,6 @@ namespace WinSW
priority: this.descriptor.Priority,
callback: OnProcessCompleted,
logHandler: logHandler,
redirectStdin: redirectStdin,
hideWindow: this.descriptor.HideWindow);
}
}