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

Allow Control-C to gracefully exit a Facedancer emulation #119

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

antoinevg
Copy link
Member

@antoinevg antoinevg commented Sep 26, 2024

This PR attempts to resolve the tension between:

  • Being able to exit an emulation in order for a) the --suggest argument to work and b) just having something nicer than crashing out of the emulation with a SIGINT versus…
  • Not interfering with any external scripts running one or more emulations.

I propose that we dedicate an unused key-combination (at the time of writing this is Control-E) that can be polled for in an exit_handler() co-routine.

The final approach taken is to catch the KeyboardInterrupt exception in the default_main() helper function allowing users to gracefully exit from the emulation by pressing Control-C.

For users who may require different behavior a new example has been added: examples/coroutine.py which demonstrates how to write a custom default_main function and the use of coroutines.


Closes #118

@antoinevg antoinevg changed the title Add a keyboard shortcut to gracefully exit a Facedancer emulation Allow Control-C to gracefully exit a Facedancer emulation Sep 30, 2024
@antoinevg antoinevg marked this pull request as ready for review October 1, 2024 16:39
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.

Facedancer --suggest mode doesn't print suggestions, as Ctrl-C is no longer caught
1 participant