Unhide the cursor before exiting for termination signals #155
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
before.mov
After changes
after.mov
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