Interface Terminal.SignalHandler

All Known Implementing Classes:
NativeSignalHandler
Enclosing interface:
Terminal

public static interface Terminal.SignalHandler
Interface for handling terminal signals.

The SignalHandler interface defines the contract for objects that can respond to terminal signals. When a signal is raised, the corresponding handler's handle(Signal) method is called with the signal that was raised.

JLine provides two predefined signal handlers:

  • SIG_DFL - Default signal handler that uses the JVM's default behavior
  • SIG_IGN - Ignores the signal and performs no special processing

Example usage with a custom handler:

 Terminal terminal = TerminalBuilder.terminal();

 // Create a custom signal handler
 SignalHandler handler = signal -> {
     if (signal == Signal.INT) {
         terminal.writer().println("\nInterrupted!");
         terminal.flush();
     }
 };

 // Register the handler for the INT signal
 terminal.handle(Signal.INT, handler);
 
See Also: