SideCARCLI–Finish process after some time
Summary links SideCarCLI
( Description : SideCar for CLI applications. Interceptors for Line, Finish, Timer . See Code )One of the feature is to let the original process execute just a limited amount of time. For this, I have defined an option
var maxSeconds = app.Option(“-mS|–maxSeconds”, “max seconds for the StartApp to run”, CommandOptionType.SingleOrNoValue);
and the code for waiting is
Process p = new Process()
{
StartInfo = pi
};//code
var res=p.WaitForExit(this.MaxSeconds);
//code
if (res)
{
exitCode = p.ExitCode;
RunFinishInterceptors(exitCode);
}
else
{
Console.WriteLine($”timeout {MaxSeconds} elapsed”);
exitCode = int.MinValue;
}
where the default value for this.MaxSeconds is –1 – wait undefinetely
Leave a Reply