Hello,
I have an application that launch several goroutines like this:
func ExecProcess(cmdname string, params *[]string) {
cmd := exec.Command(cmdname, (*params)[0:]...)
if err := cmd.Start(); err != nil {
println(err.Error())
return
}
// Wait for the process to finish or kill it after a timeout (whichever happens first):
done := make(chan error, 1)
go func() {
done <- cmd.Wait()
}()
select {
case <-time.After(45 * time.Second):
if err := cmd.Process.Kill(); err != nil {
println("failed to kill process: " + err.Error())
}
println("process killed as timeout reached")
case err := <-done:
if err != nil {
println("process finished with error = " + err.Error())
}
}
}
Under linux, my application is killed (signal killed) with the following message:
process finished with error = signal killed
Do you know how to prevent that?
Regards