darkphase / klish

Tool for Implementing Custom Shells

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Key value showing instead of being interpreted

GoogleCodeExporter opened this issue · comments

>What steps will reproduce the problem?
1. Run Klish with any XML config (default)
2. Keep pressing a non-letter key (del or any arrow works)
3. If pressing an arrow, the cursor correctly moves but if I keep the key 
pressed, sometimes it prints [C [D or any special character corresponding to 
the smashed key (one for every not caught to move next letter). I then have to 
manually erase by just going slower.

>What is the expected output? What do you see instead?
I would expect to see none of those characters printed out.

>What version of the product are you using? On what operating system?
1.6.7 on Debian. My terminal is cygwin (im sshing Debian from Windows).

>Please provide any additional information below.
I suspect that we might be in the process of checking the line and therefore 
the key is not intercepted to be analyzed. I don't know where to start looking 
to help solve it.

I've also seen that issue on console terminal.

Original issue reported on code.google.com by corent...@gmail.com on 24 Jan 2014 at 1:18

Hi

I can't reproduce it.
I have tried on Ubuntu.
I have tried on Ubuntu with ssh to another Ubuntu.
Additionaly the output of [C [D and another unknown characters was disabled in 
1.6.7 release.
Please try it on Debian itself or with ssh from another Linux to Debian.
I'm not sure but probably it's problem of Windows terminal or ssh client.

Original comment by serj.kalichev@gmail.com on 24 Jan 2014 at 9:59

Hi Serj,

Thanks for trying it! I'm going to try again and will get back to you with more 
details.

It also happens to me when I press quickly an arrow.

Original comment by corent...@gmail.com on 24 Jan 2014 at 9:39

Hello Serj,

I tried it directly on the system and it works find.
However, I am getting the error when I ssh.

Could you try to ssh in your system? (I ssh from windows).

Do you use windows? If so, which terminal do you use to ssh into a linux 
system. What configuration?

I have the issue in Klish but not on bash. I don't know what is done 
differently between the two.

Thanks!

Original comment by corent...@gmail.com on 4 Feb 2014 at 12:04

I figured out a potential issue (I think):

in tinyrl/vt100/vt100.c, line 76. There is a potential race condition between 
writing into stdin and reading using fgetc.

If we get an escape character. We start in the loop. If the [ and letter(A to D 
for arrows) hasn't been received, then it will cancel the escape, discarding 
the [ if it received one (which explains why sometimes it prints [D and 
sometimes D))

Welcome to Clish
> [DD[D[D[DD[D[DD

We need some kind of timeout mechanism in that while loop so we wait a little 
bit if we don't get an expected character.

Original comment by corent...@gmail.com on 4 Feb 2014 at 2:42

I wrote a patch for it.
I don't know how to run UT on it.

Let me know if I should create a login on libcode and push it to the repo or if 
you are going to do it.

Let me know how testing goes too :)

Original comment by corent...@gmail.com on 4 Feb 2014 at 5:44

Attachments:

Hello.

I don't use Windows. May be I'll boot it on virtual machine while testing.
Thanks for the patch! You have show the possibility of races.

But note klish has a timeout feature. When no key is pressed for a long time 
the klish will exit automatically. It's implemented for the case when admin 
didn't close the session and then gone away.

Cause of this feature the klish can't be blocked without timeout. I use 
select() in tinyrl_vt100_getchar() to implement timeout. Probably it will be 
good to use tinyrl_vt100_getchar() instead the fgetc(). I'll inspect it in a 
several days when I have some free time for this.

Thanks.

Original comment by serj.kalichev@gmail.com on 5 Feb 2014 at 6:36

Hi
I have made some fixes to tinyrl. It still hard for me to reproduce the problem 
without windows. Please try the latest klish GIT revision (1.6 or master 
branch).

Original comment by serj.kalichev@gmail.com on 15 Feb 2014 at 3:16

  • Changed state: Started
Hello,

I checked out master.
I am not able to reproduce anymore. Good job fixing it!

Thanks!
Co

Original comment by corent...@gmail.com on 16 Feb 2014 at 8:15

Original comment by serj.kalichev@gmail.com on 17 Feb 2014 at 7:39

  • Changed state: Fixed