How to handle signals gracefully with Jline3?

Skip to first unread message

Wang Zhong

May 30, 2019, 3:52:37 AM5/30/19
to jline-users

Is there any code example about how to handle signals in Jline3? 

I had a look at your code and noticed that Jline3 implements several classes to handle signals. It seems that the recommended way to handle signals is by calling the handle() method defined by Terminal like this
        SignalHandler intHandler = terminal.handle(Signal.INT, s -> {
            Job current = session.foregroundJob();
            if (current != null) {

Currently I set SignalHandle like this:

    Signal.handle(new Signal("INT"), (sig) -> {

And it seems the handler is replaced by some unknown handler sometimes.

Brad Wood

May 30, 2019, 10:18:35 AM5/30/19
I'm using JLine from CFML and I register my handler class with the terminal builder.  You can see that line here:

 My signal handler is here and simply interrupts the main thread of my console app when Ctrl-C is pressed:

That is a CFML class that implements org.jline.terminal.Terminal$SignalHandler



Developer Advocate
Ortus Solutions, Corp 

ColdBox Platform: 

You received this message because you are subscribed to the Google Groups "jline-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit

Wang Zhong

May 31, 2019, 4:05:55 AM5/31/19
to jline-users
Thanks for replying, I will have a look at your example! Btw, stared :P
To unsubscribe from this group and stop receiving emails from it, send an email to
Reply all
Reply to author
0 new messages