1

I want to terminate the Apache Mina Ssh Server on the basis of Ctrl+c that are basically SigInt I searched on the google and have looked there are SignalListener but not find any good example of it.

Please share any good example and use in ssh server.

A listener will only trigger if any Sigint or a Signal is sent, Am I right ?

1
  • 1
    Did you manage to catch the Ctrl + C? I am have the same question haha Commented Aug 23, 2019 at 12:46

1 Answer 1

0

To get access to signal handling you have to use sun's private classes, which makes your code not portable any mode. Anyway...

    import sun.misc.Signal;

    public static void main(String[] args) {
        registerSignalHandler();
    }

    @SuppressWarnings("restriction")
    private static void registerSignalHandler() {
        Signal.handle(new Signal("HUP"), (Signal signal) -> {
             System.out.println("Hello signal!");
        });
    }
1
  • Thanks for your answer but I want specifically to Apache mina sshd server. And I want to work with Sigs.
    – Root
    Commented Feb 27, 2017 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.