mirror of
https://github.com/chainreactors/spray.git
synced 2026-10-28 19:40:49 +00:00
fix ctrl+c cannot exit
This commit is contained in:
1 parent
53d8c8f23d
commit
60844e9089
3 files changed
+18
-7
No files matched your search
+15
-5
@@ -135,12 +135,22 @@ func Spray() {
|
||||
}
|
||||
|
||||
go func() {
|
||||
c := make(chan os.Signal, 2)
|
||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
exitChan := make(chan os.Signal, 2)
|
||||
signal.Notify(exitChan, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
go func() {
|
||||
<-c
|
||||
logs.Log.Important("exit signal, save stat and exit")
|
||||
canceler()
|
||||
sigCount := 0
|
||||
for {
|
||||
<-exitChan
|
||||
sigCount++
|
||||
if sigCount == 1 {
|
||||
logs.Log.Infof("Exit signal received, saving task and exiting...")
|
||||
canceler()
|
||||
} else if sigCount == 2 {
|
||||
logs.Log.Infof("forcing exit...")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}()
|
||||
|
||||
|
||||
Reference in new issue
Block a user