Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>EDIT2</strong>: this may also help: <a href="https://stackoverflow.com/questions/2541475/capture-sigint-in-java">Capture SIGINT in Java</a></p> <p><a href="http://twit88.com/blog/2007/09/27/do-a-graceful-shutdown-of-your-java-application-when-ctr-c-kill/" rel="nofollow noreferrer">This</a> and <a href="http://twit88.com/blog/2008/02/06/java-signal-handling/" rel="nofollow noreferrer">this</a> appear to be what you want.</p> <p>Ctrl-C and other command send "signals" to your program, and if you write code to "catch" catch those signals, you can change how your program reacts. Ideally, you would want ctrl-c to terminate the program, as it's what the user expects, so keep in mind that you should tell the user why it's not terminating if you change the program's response.</p> <p><strong>Edit3</strong>: Cat's suggestion of a keylistener is your next best bet if you can't catch and dismiss the event yourself. <a href="http://www.darkcoding.net/software/non-blocking-console-io-is-not-possible/" rel="nofollow noreferrer">Halway down the page is an example of how to do it for java in linux/Windows - it's not a portable thing.</a> Essentially, your program will be handling keyboard events instead of the console sending the keybaord events to it. This means the command line is bypassed, and cannot read the ctrl-c call. I'd write code, but I'm at work now; Wednesdays are a long day for me. If you haven't gotten it by the time I get home, I'll take a look at writing some examples.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload