mirror of https://github.com/winsw/winsw
Leave STDIN open (#738)
parent
16bbefdaae
commit
8cc17b5aa6
|
@ -185,7 +185,6 @@ namespace WinSW.Util
|
||||||
/// <param name="workingDirectory">Working directory</param>
|
/// <param name="workingDirectory">Working directory</param>
|
||||||
/// <param name="priority">Priority</param>
|
/// <param name="priority">Priority</param>
|
||||||
/// <param name="callback">Completion callback. If null, the completion won't be monitored</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>
|
/// <param name="logHandler">Log handler. If enabled, logs will be redirected to the process and then reported</param>
|
||||||
public static void StartProcessAndCallbackForExit(
|
public static void StartProcessAndCallbackForExit(
|
||||||
Process processToStart,
|
Process processToStart,
|
||||||
|
@ -195,7 +194,6 @@ namespace WinSW.Util
|
||||||
string? workingDirectory = null,
|
string? workingDirectory = null,
|
||||||
ProcessPriorityClass? priority = null,
|
ProcessPriorityClass? priority = null,
|
||||||
ProcessCompletionCallback? callback = null,
|
ProcessCompletionCallback? callback = null,
|
||||||
bool redirectStdin = true,
|
|
||||||
LogHandler? logHandler = null,
|
LogHandler? logHandler = null,
|
||||||
bool hideWindow = false)
|
bool hideWindow = false)
|
||||||
{
|
{
|
||||||
|
@ -205,7 +203,6 @@ namespace WinSW.Util
|
||||||
ps.WorkingDirectory = workingDirectory ?? ps.WorkingDirectory;
|
ps.WorkingDirectory = workingDirectory ?? ps.WorkingDirectory;
|
||||||
ps.CreateNoWindow = hideWindow;
|
ps.CreateNoWindow = hideWindow;
|
||||||
ps.UseShellExecute = false;
|
ps.UseShellExecute = false;
|
||||||
ps.RedirectStandardInput = redirectStdin;
|
|
||||||
ps.RedirectStandardOutput = logHandler?.OutFileDisabled == false;
|
ps.RedirectStandardOutput = logHandler?.OutFileDisabled == false;
|
||||||
ps.RedirectStandardError = logHandler?.ErrFileDisabled == false;
|
ps.RedirectStandardError = logHandler?.ErrFileDisabled == false;
|
||||||
|
|
||||||
|
|
|
@ -330,10 +330,8 @@ namespace WinSW
|
||||||
this.ExtensionManager.FireOnWrapperStarted();
|
this.ExtensionManager.FireOnWrapperStarted();
|
||||||
|
|
||||||
var executableLogHandler = this.CreateExecutableLogHandler();
|
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.ExtensionManager.FireOnProcessStarted(this.process);
|
||||||
|
|
||||||
this.process.StandardInput.Close(); // nothing for you to read!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -371,7 +369,7 @@ namespace WinSW
|
||||||
executable ??= this.descriptor.Executable;
|
executable ??= this.descriptor.Executable;
|
||||||
|
|
||||||
// TODO: Redirect logging to Log4Net once https://github.com/kohsuke/winsw/pull/213 is integrated
|
// 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);
|
Log.Debug("WaitForProcessToExit " + this.process.Id + "+" + stopProcess.Id);
|
||||||
this.WaitForProcessToExit(this.process);
|
this.WaitForProcessToExit(this.process);
|
||||||
|
@ -449,7 +447,7 @@ namespace WinSW
|
||||||
ServiceApis.SetServiceStatus(handle, this.wrapperServiceStatus);
|
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
|
// Define handler of the completed process
|
||||||
void OnProcessCompleted(Process proc)
|
void OnProcessCompleted(Process proc)
|
||||||
|
@ -496,7 +494,6 @@ namespace WinSW
|
||||||
priority: this.descriptor.Priority,
|
priority: this.descriptor.Priority,
|
||||||
callback: OnProcessCompleted,
|
callback: OnProcessCompleted,
|
||||||
logHandler: logHandler,
|
logHandler: logHandler,
|
||||||
redirectStdin: redirectStdin,
|
|
||||||
hideWindow: this.descriptor.HideWindow);
|
hideWindow: this.descriptor.HideWindow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue