mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 11:58:20 +08:00
lib/atexit: add SIGTERM to signals which run the exit handlers on unix
This commit is contained in:
parent
7267d19ad8
commit
fef73763aa
|
@ -31,11 +31,10 @@ func Register(fn func()) FnHandle {
|
|||
fns[&fn] = true
|
||||
fnsMutex.Unlock()
|
||||
|
||||
// Run AtExit handlers on SIGINT or SIGTERM so everything gets
|
||||
// tidied up properly
|
||||
// Run AtExit handlers on exitSignals so everything gets tidied up properly
|
||||
registerOnce.Do(func() {
|
||||
exitChan = make(chan os.Signal, 1)
|
||||
signal.Notify(exitChan, os.Interrupt) // syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT
|
||||
signal.Notify(exitChan, exitSignals...)
|
||||
go func() {
|
||||
sig := <-exitChan
|
||||
if sig == nil {
|
||||
|
|
9
lib/atexit/atexit_other.go
Normal file
9
lib/atexit/atexit_other.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
//+build windows plan9
|
||||
|
||||
package atexit
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
var exitSignals = []os.Signal{os.Interrupt}
|
10
lib/atexit/atexit_unix.go
Normal file
10
lib/atexit/atexit_unix.go
Normal file
|
@ -0,0 +1,10 @@
|
|||
//+build !windows,!plan9
|
||||
|
||||
package atexit
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
var exitSignals = []os.Signal{syscall.SIGINT, syscall.SIGTERM} // Not syscall.SIGQUIT as we want the default behaviour
|
Loading…
Reference in New Issue
Block a user