Return correct exit code upon signal + SIGQUIT now quits without cleanup

Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume@charmes.net> (github: creack)
This commit is contained in:
Guillaume J. Charmes 2014-04-02 05:56:11 -07:00
parent 9687c087ab
commit 3b3f4bf052
No known key found for this signature in database
GPG key ID: B33E4642CB6E3FF3

View file

@ -54,11 +54,16 @@ func InitServer(job *engine.Job) engine.Status {
c := make(chan os.Signal, 1)
gosignal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
sig := <-c
log.Printf("Received signal '%v', starting shutdown of docker...\n", sig)
utils.RemovePidFile(srv.runtime.Config().Pidfile)
srv.Close()
os.Exit(0)
for sig := range c {
log.Printf("Received signal '%v', starting shutdown of docker...\n", sig)
switch sig {
case os.Interrupt, syscall.SIGTERM:
utils.RemovePidFile(srv.runtime.Config().Pidfile)
srv.Close()
case syscall.SIGQUIT:
}
os.Exit(128 + int(sig.(syscall.Signal)))
}
}()
job.Eng.Hack_SetGlobalVar("httpapi.server", srv)
job.Eng.Hack_SetGlobalVar("httpapi.runtime", srv.runtime)