From fc40bad092359f25a0c56b0d99594fe801858f40 Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Sat, 21 May 2022 11:38:02 -0400 Subject: [PATCH] fix: stop jobs on exit --- main.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index c0fce06..2f6a900 100644 --- a/main.go +++ b/main.go @@ -221,6 +221,8 @@ input: } fmt.Printf("\u001b[7m∆\u001b[0m" + strings.Repeat(" ", termwidth - 1) + "\r") } + + exit(0) } func continuePrompt(prev string) (string, error) { @@ -296,10 +298,17 @@ func contains(s []string, e string) bool { } func exit(code int) { - // wait for all timers to finish before exiting - for { - if timers.running == 0 { - os.Exit(code) + jobs.stopAll() + + // wait for all timers to finish before exiting. + // only do that when not interactive + if !interactive { + for { + if timers.running == 0 { + os.Exit(code) + } } } + + os.Exit(code) }