Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhide the cursor before exiting for termination signals #155

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

zimeg
Copy link
Contributor

@zimeg zimeg commented Aug 19, 2023

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 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
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

  • A few other changes are included in these commits and separated by commit. Happy to adjust these to any preference!

@kernel-sanders
Copy link

This solves my biggest problem with this library!

Unfortunately, it doesn't compile on Windows: spinner/spinner.go:359:14: undefined: syscall.Kill

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants