osutil: pid 1 should exit directly instead of trying to kill itself

This commit is contained in:
Xiang Li 2015-02-19 14:52:32 -08:00
parent 88994f9ec8
commit 7ae94f2bf0

View File

@ -59,13 +59,18 @@ func HandleInterrupts() {
interruptExitMu.Lock()
log.Printf("received %v signal, shutting down", sig)
log.Printf("received %v signal, shutting down...", sig)
for _, h := range ihs {
h()
}
signal.Stop(notifier)
syscall.Kill(syscall.Getpid(), sig.(syscall.Signal))
pid := syscall.Getpid()
// exit directly if it is the "init" process, since the kernel will not help to kill pid 1.
if pid == 1 {
os.Exit(0)
}
syscall.Kill(pid, sig.(syscall.Signal))
}()
}