From 7b7417c92eebbcc602f72f5ee23e4b9561b4d6fa Mon Sep 17 00:00:00 2001 From: Niko Kurtti Date: Mon, 26 Oct 2020 15:01:39 +0200 Subject: [PATCH] Test process exists before signaling --- pkg/supervisor/supervisor.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/supervisor/supervisor.go b/pkg/supervisor/supervisor.go index bc8eb81..6b1c63f 100644 --- a/pkg/supervisor/supervisor.go +++ b/pkg/supervisor/supervisor.go @@ -62,9 +62,12 @@ func (s *Supervisor) Start() error { if sig == syscall.SIGCHLD { continue } - err := s.cmd.Process.Signal(sig) - if err != nil { - log.Printf("Signal propegation failed: %v\n", err) + // Test that process still exists + if err := s.cmd.Process.Signal(syscall.Signal(0)); err == nil { + err := s.cmd.Process.Signal(sig) + if err != nil { + log.Printf("Signal propegation failed: %v\n", err) + } } } }()