Application crash with goroutines (receive signal killed)


(Fookiwara) #1

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


(Sean Killian) #2

Hi, @Fookiwara, are you saying the Go program running your ExecProcess function is being killed or the program you’re running from ExecProcess? If the latter, then it looks to me like it’s being killed by the timeout.


(Fookiwara) #3

It was just a problem of lack of RAM