Skip to content

Instantly share code, notes, and snippets.

@kazeburo
Created December 7, 2018 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazeburo/dbbdb8198c72addc2fcafbce79d5f6b6 to your computer and use it in GitHub Desktop.
Save kazeburo/dbbdb8198c72addc2fcafbce79d5f6b6 to your computer and use it in GitHub Desktop.
diff --git a/starter.go b/starter.go
index c65ce00..4d47000 100644
--- a/starter.go
+++ b/starter.go
@@ -517,7 +517,6 @@ func (s *Starter) StartWorker(sigCh chan os.Signal, ch chan processState) *os.Pr
sigs = append(sigs, sig)
}
}
-
// if received any signals, during the wait, we bail out
gotSig := false
if len(sigs) > 0 {
@@ -534,8 +533,10 @@ func (s *Starter) StartWorker(sigCh chan os.Signal, ch chan processState) *os.Pr
}
// Check if we can find a process by its pid
- p, err := os.FindProcess(pid)
- if gotSig || err == nil {
+ p, _ := os.FindProcess(pid)
+ var wstatus syscall.WaitStatus
+ waitpid, _ := syscall.Wait4(pid, &wstatus, syscall.WNOHANG, nil)
+ if gotSig || waitpid <= 0 {
// No error? We were successful! Make sure we capture
// the program exiting
go func() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment