I was facing similar problem before. This is how I get it resolved.
First, register a signal handler in your Jython script by:
import signal
def intHandler(signum, frame):
print "Shutting down.."
System.exit(1)
# Set the signal handler
signal.signal(signal.SIGINT, intHandler)
signal.signal(signal.SIGTERM, intHandler)
This will register the signal handler for the Jython script to handle CTRL+C keyboard input.
However, the default console class org.python.util.JLineConsole treats ctrl+C as a normal character inputs.
So, Secondly - need to change the python.console to an alternative console class org.python.core.PlainConsole by either change the Jython property:
python.console=org.python.core.PlainConsole
or add the jvm argument:
-Dpython.console=org.python.core.PlainConsole
This will help you to shutdown the program after CTRL+C is pressed.