From 8f267d80f2eb68998661a325c0e53fca4485e626 Mon Sep 17 00:00:00 2001 From: SteelPhase Date: Wed, 22 Aug 2018 20:15:10 -0400 Subject: [PATCH] Potentially resolve issue with os signals (#144) * change error format * capture SIGTERM for upstart, ignore SIGKILL * for windows only notify on SIGINT --- service_upstart_linux.go | 3 ++- service_windows.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/service_upstart_linux.go b/service_upstart_linux.go index 800db35..bf79ded 100644 --- a/service_upstart_linux.go +++ b/service_upstart_linux.go @@ -11,6 +11,7 @@ import ( "os/signal" "regexp" "strings" + "syscall" "text/template" "time" ) @@ -186,7 +187,7 @@ func (s *upstart) Run() (err error) { s.Option.funcSingle(optionRunWait, func() { var sigChan = make(chan os.Signal, 3) - signal.Notify(sigChan, os.Interrupt, os.Kill) + signal.Notify(sigChan, syscall.SIGTERM, os.Interrupt) <-sigChan })() diff --git a/service_windows.go b/service_windows.go index bb53445..95ccaed 100644 --- a/service_windows.go +++ b/service_windows.go @@ -268,7 +268,7 @@ func (ws *windowsService) Run() error { sigChan := make(chan os.Signal) - signal.Notify(sigChan, os.Interrupt, os.Kill) + signal.Notify(sigChan, os.Interrupt) <-sigChan @@ -311,7 +311,7 @@ func (ws *windowsService) Status() (Status, error) { case svc.Stopped: return StatusStopped, nil default: - return StatusUnknown, fmt.Errorf("unknown status %s", status) + return StatusUnknown, fmt.Errorf("unknown status %v", status) } }