github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/lib/atexit/atexit_unix.go (about) 1 //go:build !windows && !plan9 2 3 package atexit 4 5 import ( 6 "os" 7 "syscall" 8 9 "github.com/rclone/rclone/lib/exitcode" 10 ) 11 12 var exitSignals = []os.Signal{syscall.SIGINT, syscall.SIGTERM} // Not syscall.SIGQUIT as we want the default behaviour 13 14 // exitCode calculates the exit code for the given signal. Many Unix programs 15 // exit with 128+signum if they handle signals. Most shell also implement the 16 // same convention if a program is terminated by an uncaught and/or fatal 17 // signal. 18 func exitCode(sig os.Signal) int { 19 if real, ok := sig.(syscall.Signal); ok && int(real) > 0 { 20 return 128 + int(real) 21 } 22 23 return exitcode.UncategorizedError 24 }