You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "waseem.farooqui" <wa...@gmail.com> on 2017/03/02 10:55:56 UTC

How to handle Ctrl+C and other Sigint

Hi, 

I am new in Apache mina and have just follow the embedded server tutorial
but I have some problem in it. 

*  When I typed Ctrl+C from the client nix based terminal It prints some
unicodes but in real server its not print on clients terminal How Can I
handle this in my sshd server or which class handle this type of request
Kindly share a sample code. 
*  The server should terminate on this should I handle it myself or apache
mina have some class or it. 
*   DEL or Backspace and Tab is also not working how I could handle it. 

Thanks,



--
View this message in context: http://apache-mina.10907.n7.nabble.com/How-to-handle-Ctrl-C-and-other-Sigint-tp52319.html
Sent from the Apache MINA Developer Forum mailing list archive at Nabble.com.

Re: How to handle Ctrl+C and other Sigint

Posted by Guillaume Nodet <gn...@apache.org>.
You need to configure the terminal correctly on the client and server side,
you also need to process the signals correctly.
For example, Ctrl+C is just the character 0x03 in the input stream.  Wether
you should terminate or not is your decision.  Del, backspace and tab are
also characters in the input stream, so it really depends on what kind of
shell you use on the server side.

If you want a complete example, you may want to have a look at JLine.
There is some sample integration code  with SSHD for both the client and
server side which I haven't committed to the master branch yet:

https://github.com/gnodet/jline3/blob/wip-ssh/remote-ssh/src/main/java/org/jline/builtins/ssh/



2017-03-02 11:55 GMT+01:00 waseem.farooqui <wa...@gmail.com>:

> Hi,
>
> I am new in Apache mina and have just follow the embedded server tutorial
> but I have some problem in it.
>
> *  When I typed Ctrl+C from the client nix based terminal It prints some
> unicodes but in real server its not print on clients terminal How Can I
> handle this in my sshd server or which class handle this type of request
> Kindly share a sample code.
> *  The server should terminate on this should I handle it myself or apache
> mina have some class or it.
> *   DEL or Backspace and Tab is also not working how I could handle it.
>
> Thanks,
>
>
>
> --
> View this message in context: http://apache-mina.10907.n7.
> nabble.com/How-to-handle-Ctrl-C-and-other-Sigint-tp52319.html
> Sent from the Apache MINA Developer Forum mailing list archive at
> Nabble.com.
>



-- 
------------------------
Guillaume Nodet

Re: How to handle Ctrl+C and other Sigint

Posted by Guillaume Nodet <gn...@apache.org>.
SSHd won't do anything about it, it simply focuses on transporting the data
and conveying all the needed informations.
It's the responsibility of the shell to implement things correctly, so the
only thing I can do (and did already) is to point you to a java shell which
is doing this.  If you write your own commands and shell, then you'll have
to do it yourself.

2017-03-03 6:29 GMT+01:00 waseem.farooqui <wa...@gmail.com>:

> Yes I research on reading from the input stream IN case of Ctrl+c terminal
> sends 3 as a byte data and same in case of others.
> But should I handle all the special inputs  myself or is there any class ?
> I have search a lot for its example but not find any.
>
>
>
> --
> View this message in context: http://apache-mina.10907.n7.
> nabble.com/How-to-handle-Ctrl-C-and-other-Sigint-tp52319p52361.html
> Sent from the Apache MINA Developer Forum mailing list archive at
> Nabble.com.
>



-- 
------------------------
Guillaume Nodet

Re: How to handle Ctrl+C and other Sigint

Posted by "waseem.farooqui" <wa...@gmail.com>.
Yes I research on reading from the input stream IN case of Ctrl+c terminal
sends 3 as a byte data and same in case of others.
But should I handle all the special inputs  myself or is there any class ?
I have search a lot for its example but not find any.  



--
View this message in context: http://apache-mina.10907.n7.nabble.com/How-to-handle-Ctrl-C-and-other-Sigint-tp52319p52361.html
Sent from the Apache MINA Developer Forum mailing list archive at Nabble.com.

Re: How to handle Ctrl+C and other Sigint

Posted by elijah baley <e_...@outlook.com>.
The answer is very long and complex however here are a few pointers


- See Signal(s) and how to register for them

- Do some research into reading from the peer input stream and detecting key combinations and/or special characters.


________________________________
From: waseem.farooqui <wa...@gmail.com>
Sent: Thursday, March 2, 2017 12:55 PM
To: dev@mina.apache.org
Subject: How to handle Ctrl+C and other Sigint

Hi,

I am new in Apache mina and have just follow the embedded server tutorial
but I have some problem in it.

*  When I typed Ctrl+C from the client nix based terminal It prints some
unicodes but in real server its not print on clients terminal How Can I
handle this in my sshd server or which class handle this type of request
Kindly share a sample code.
*  The server should terminate on this should I handle it myself or apache
mina have some class or it.
*   DEL or Backspace and Tab is also not working how I could handle it.

Thanks,



--
View this message in context: http://apache-mina.10907.n7.nabble.com/How-to-handle-Ctrl-C-and-other-Sigint-tp52319.html
Apache MINA Developer Forum - How to handle Ctrl+C and other Sigint<http://apache-mina.10907.n7.nabble.com/How-to-handle-Ctrl-C-and-other-Sigint-tp52319.html>
apache-mina.10907.n7.nabble.com
How to handle Ctrl+C and other Sigint. Hi, I am new in Apache mina and have just follow the embedded server tutorial but I have some problem in it. * When I typed Ctrl+C from the client nix...



Sent from the Apache MINA Developer Forum mailing list archive at Nabble.com.