Hi.
For prototype I’ve created on c# program, which as income argument receive number.
This number is timeout in second.
Every second it writing to output of console number of second.
Every 10 second program clean screen.
In golang I’ve written code, which call c# exe program with parameters 20 (Means time out 20 seconds)
func ExecuteProcess (path string, parameters []string)(error){
cmd := exec.Command(path, parameters...)
fmt.Printf("[ExecuteProcess].Running command and waiting for it to finish...\n")
output, err := cmd.CombinedOutput()
if err != nil {
fmt.Println(fmt.Sprint(err) + ": " + string(output) + "\n")
return err
} else {
fmt.Println(string(output))
}
return nil
}
When I start this program I see output:
[ExecuteProcess].Running command and waiting for it to finish…
exit status 3762504530: Wait 0 seconds
Wait 1 seconds
Wait 2 seconds
Wait 3 seconds
Wait 4 seconds
Wait 5 seconds
Wait 6 seconds
Wait 7 seconds
Wait 8 seconds
Wait 9 seconds
Wait 10 secondsUnhandled Exception: System.IO.IOException: The handle is invalid.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)
at System.Console.Clear()
at TestExe.Program.Main(String args)exit status 3762504530Program has finished.
When called program clean the screen I see error: the handle is invalid.
Could you advice how to fix this error? And wait when program will closed by it self?