angr-management icon indicating copy to clipboard operation
angr-management copied to clipboard

Support Ctrl-C to interrupt console

Open mborgerson opened this issue 4 years ago • 5 comments

Long running tasks in the console cannot be interrupted from within the GUI console view (e.g. a while(1)). However, I can Ctrl-C within the terminal that I launched angr-management from and it will stop the task.

I think the right thing to do here is to respond to Ctrl-C (or whatever binding) as IPython would when launched from a terminal:

In [1]: while True:
   ...:     pass
   ...: 
^C---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-1-414c137564b4> in <module>
      1 while True:
----> 2     pass
      3 

KeyboardInterrupt: 

In [2]: 

mborgerson avatar Jun 19 '21 00:06 mborgerson

piggyback on https://github.com/angr/angr-management/pull/277?

rhelmot avatar Jun 19 '21 00:06 rhelmot

We should not have long-running tasks in the main thread. All long-running tasks should be executed as jobs in other threads, then we can kill jobs at any time we want.

ltfish avatar Jun 19 '21 09:06 ltfish

This issue has been marked as stale because it has no recent activity. Please comment or add the pinned tag to prevent this issue from being closed.

github-actions[bot] avatar Jun 15 '22 02:06 github-actions[bot]

Because QT does not really allow objects to concurrently exist in multiple threads, our kernel has to run in the same thread as the GUI application if we want it to be able to seamlessly be able to manipulate these objects.

I think the only possible decent resolution to this would be, if this is possible, to have QT listen for the Ctrl-C key binding in a non-main thread, then do os.kill(os.getpid(), signal.SIGINT) as a callback; this would trigger the sigint handler installed by the kernel, which would propagate it to IPython. If QT must listen to keybind events in the main thread, I don't know of an acceptable solution for this issue.

zwimer avatar Dec 08 '22 00:12 zwimer

I could not figure out how to do this from a different thread.

zwimer avatar Dec 13 '22 04:12 zwimer