|
@@ -34,9 +34,8 @@ func Trap(cleanup func()) {
|
|
case os.Interrupt, syscall.SIGTERM:
|
|
case os.Interrupt, syscall.SIGTERM:
|
|
// If the user really wants to interrupt, let him do so.
|
|
// If the user really wants to interrupt, let him do so.
|
|
if atomic.LoadUint32(&interruptCount) < 3 {
|
|
if atomic.LoadUint32(&interruptCount) < 3 {
|
|
- atomic.AddUint32(&interruptCount, 1)
|
|
|
|
// Initiate the cleanup only once
|
|
// Initiate the cleanup only once
|
|
- if atomic.LoadUint32(&interruptCount) == 1 {
|
|
|
|
|
|
+ if atomic.AddUint32(&interruptCount, 1) == 1 {
|
|
// Call cleanup handler
|
|
// Call cleanup handler
|
|
cleanup()
|
|
cleanup()
|
|
os.Exit(0)
|
|
os.Exit(0)
|