This PR unhides the cursor after a termination signal is sent while the spinner is active to prevent the cursor from disappearing in some terminals.
The signals listened for before termination are SIGHUP, SIGINT, SIGTERM, SIGQUIT – all gathered from the GNU termination signals page – and a custom syscall.Signal(0x0).
The syscall.Signal(0x0) is used to signal a successful .Stop() of the spinner and can safely be used as a termination signal since it doesn't send an actual signal, it only checks that the current process exists.
Preview
On some terminals, pressing CTRL-C would quit the program without unhiding the cursor. This example is shown with ANSI terminal:
Before changes
https://github.com/briandowns/spinner/assets/18134219/c04b9098-a889-46f7-ac5f-fea25d399527
After changes
https://github.com/briandowns/spinner/assets/18134219/e1b8d6f9-30b9-4ed6-bcbf-1a9f6eb86a3e
Reviewers
A small program to test with is ready in this repo to verify various exit codes and conditions in certain cases. Different testing cases are listed in SIGNALS.md if you want to try these yourself!
Notes
A few other changes are included in these commits and separated by commit. Happy to adjust these to any preference!
Summary
This PR unhides the cursor after a termination signal is sent while the spinner is active to prevent the cursor from disappearing in some terminals.
The signals listened for before termination are
SIGHUP
,SIGINT
,SIGTERM
,SIGQUIT
– all gathered from the GNU termination signals page – and a customsyscall.Signal(0x0)
.The
syscall.Signal(0x0)
is used to signal a successful.Stop()
of the spinner and can safely be used as a termination signal since it doesn't send an actual signal, it only checks that the current process exists.Preview
On some terminals, pressing
CTRL-C
would quit the program without unhiding the cursor. This example is shown withANSI
terminal:Before changes
https://github.com/briandowns/spinner/assets/18134219/c04b9098-a889-46f7-ac5f-fea25d399527After changes
https://github.com/briandowns/spinner/assets/18134219/e1b8d6f9-30b9-4ed6-bcbf-1a9f6eb86a3eReviewers
A small program to test with is ready in this repo to verify various exit codes and conditions in certain cases. Different testing cases are listed in
SIGNALS.md
if you want to try these yourself!Notes