SideCARCLI–Finish process after some time

Summary links SideCarCLI

NoName + Link 
1Description
2Specifications
3Refactor specifications and code
4Create Release
5Finish interceptors
6Send part of command to interceptors
7Line Interceptors
8Finish process after some time
9Documetation Diagram
10Technical Summary
11Create dotnet tool
( 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