INNER CODE UNIT · Go

signalProcessWithTimeout

jwilder/dockerize · exec.go:69

func signalProcessWithTimeout(process *exec.Cmd, sig os.Signal, waitDone ...<-chan struct{}) {
	process.Process.Signal(sig) // pretty sure this doesn't do anything. It seems like the signal is automatically sent to the command?
	if len(waitDone) == 0 {
		done := make(chan struct{})
		go func() {
			process.Wait()
			close(done)
		}()
		waitDone = []<-chan struct{}{done}
	}
	select {
	case <-waitDone[0]:
		return
	case <-time.After(10 * time.Second):
		log.Println("Killing command due to timeout.")
		process.Process.Kill()
	}
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…