Skip to content

Commit 4f04bb4

Browse files
authored
Merge pull request #173 from CarlJi/0303
fix: exit successfully when catch specific signal
2 parents 6a973e0 + 145bf7b commit 4f04bb4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pkg/cover/instrument.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,6 @@ func deregisterSelf(address []string) ([]byte, error) {
286286
type CallbackFunc func()
287287
288288
func watchSignal(fn CallbackFunc) {
289-
defer fn()
290-
291289
// init signal
292290
c := make(chan os.Signal, 1)
293291
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
@@ -296,7 +294,8 @@ func watchSignal(fn CallbackFunc) {
296294
log.Printf("get a signal %s", si.String())
297295
switch si {
298296
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
299-
return
297+
fn()
298+
os.Exit(0) // Exit successfully.
300299
case syscall.SIGHUP:
301300
default:
302301
return

0 commit comments

Comments
 (0)