markbates / refresh

MIT License
191 stars 30 forks source link

Send SIGTERM to give the process a chance to clean up #44

Open tachiniererin opened 4 years ago

tachiniererin commented 4 years ago

Killing the process doesn't let any defer handlers to be run. SIGTERM is a bit of a nicer approach, while still signalling the process it absolutely has to terminate, it gives a chance to clean up first.

With the most recent Go version, SIGINT should also work according to https://golang.org/pkg/os/signal/#hdr-Windows and it is also tested https://golang.org/src/os/signal/signal_windows_test.go.

Still, I propose to use SIGTERM, as it conveys the meaning better in this case, and is more portable (no extra code-paths on Windows).