Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make sure the interactive printers can cleanup after Ctrl+C
After canceling the interactive printers with Ctrl+C, `os.Exit` was directly called in the keyboard listener. Because of this the `defer` statements of the surrounding function were not called (for example `cursor.Show`) and the keyboard listener was still running. This resulted in a broken user "terminal" (no Cursor, no Ctrl+C)
- Loading branch information
Showing
4 changed files
with
45 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package internal | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
// NewCancelationSignal for keeping track of a cancelation | ||
func NewCancelationSignal() (func(), func()) { | ||
canceled := false | ||
|
||
cancel := func() { | ||
canceled = true | ||
} | ||
exit := func() { | ||
if canceled { | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
return cancel, exit | ||
} |