Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key binding ctrl-\ is broken #441

Closed
mattirn opened this issue Oct 1, 2019 · 9 comments
Closed

Key binding ctrl-\ is broken #441

mattirn opened this issue Oct 1, 2019 · 9 comments
Labels

Comments

@mattirn
Copy link
Collaborator

mattirn commented Oct 1, 2019

In nano pressing ctrl-\ ('search and replace') is causing demo application crash:

Exception in thread "main" java.io.IOError: java.io.IOException: Error executing 'stty -inlcr -icrnl min 0 time 1': stty: 'standard input': Input/output error
	at org.jline.terminal.impl.AbstractPosixTerminal.setAttributes(AbstractPosixTerminal.java:54)
	at org.jline.terminal.impl.AbstractTerminal.enterRawMode(AbstractTerminal.java:123)
	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:575)
	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:471)
	at org.apache.felix.gogo.jline.Shell.runShell(Shell.java:480)
	at org.apache.felix.gogo.jline.Shell.gosh(Shell.java:385)
	at org.apache.felix.gogo.jline.Main.main(Main.java:74)
	Suppressed: java.io.IOException: Error executing 'stty -inlcr ixon echo icanon iexten intr ^C quit ^\ susp ^Z lnext ^V discard ^O': stty: 'standard input': Input/output error
		at org.jline.utils.ExecHelper.exec(ExecHelper.java:42)
		at org.jline.terminal.impl.ExecPty.doSetAttr(ExecPty.java:101)
		at org.jline.terminal.impl.AbstractPty.setAttr(AbstractPty.java:29)
		at org.jline.terminal.impl.AbstractPosixTerminal.close(AbstractPosixTerminal.java:76)
		at org.jline.terminal.impl.PosixSysTerminal.close(PosixSysTerminal.java:95)
		at org.apache.felix.gogo.jline.Main.main(Main.java:89)
Caused by: java.io.IOException: Error executing 'stty -inlcr -icrnl min 0 time 1': stty: 'standard input': Input/output error
	at org.jline.utils.ExecHelper.exec(ExecHelper.java:42)
	at org.jline.terminal.impl.ExecPty.doSetAttr(ExecPty.java:101)
	at org.jline.terminal.impl.AbstractPty.setAttr(AbstractPty.java:29)
	at org.jline.terminal.impl.AbstractPosixTerminal.setAttributes(AbstractPosixTerminal.java:52)
@gnodet
Copy link
Member

gnodet commented Mar 6, 2023

The Ctrl+\ is usually used by the terminal to generate a SIGQUIT signal.
This is controlled by the VQUIT control char of the terminal config.

In order to bind it, the terminal must be instructed to either not translate this key into the signal (this is controlled using the LocalFlag.ISIG flag), or to change the value of the ControlChar.VQUIT.

I'm not sure about the exception reported with the exec terminal though, I can't reproduce it in the nano app.

@mattirn
Copy link
Collaborator Author

mattirn commented Mar 6, 2023

Actually it is sufficient to launch demo app and press Ctrl+\. Demo app will crash also when using jansi/JNA:

jansi:

Exception in thread "main" java.io.IOError: java.io.IOException: Input/output error
	at org.jline.keymap.BindingReader.readCharacter(BindingReader.java:170)
	at org.jline.keymap.BindingReader.readBinding(BindingReader.java:110)
	at org.jline.keymap.BindingReader.readBinding(BindingReader.java:61)
	at org.jline.reader.impl.LineReaderImpl.doReadBinding(LineReaderImpl.java:924)
	at org.jline.reader.impl.LineReaderImpl.readBinding(LineReaderImpl.java:957)
	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:652)
	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:507)
	at org.apache.felix.gogo.jline.Shell.runShell(Shell.java:480)
	at org.apache.felix.gogo.jline.Shell.gosh(Shell.java:385)
	at org.apache.felix.gogo.jline.Main.main(Main.java:74)
Caused by: java.io.IOException: Input/output error
	at java.base/java.io.FileInputStream.read0(Native Method)
	at java.base/java.io.FileInputStream.read(FileInputStream.java:231)
	at org.jline.terminal.impl.AbstractPty$PtyInputStream.read(AbstractPty.java:81)
	at org.jline.utils.NonBlockingInputStream.read(NonBlockingInputStream.java:62)
	at org.jline.utils.NonBlocking$NonBlockingInputStreamReader.read(NonBlocking.java:157)
	at org.jline.utils.NonBlockingReader.read(NonBlockingReader.java:57)
	at org.jline.keymap.BindingReader.readCharacter(BindingReader.java:160)
	... 9 more

JNA:

gogo: LastErrorException: [5] Input/output error
com.sun.jna.LastErrorException: [5] Input/output error
	at com.sun.jna.Native.invokeVoid(Native Method)
	at com.sun.jna.Function.invoke(Function.java:415)
	at com.sun.jna.Function.invoke(Function.java:361)
	at com.sun.jna.Library$Handler.invoke(Library.java:270)
	at com.sun.proxy.$Proxy0.tcsetattr(Unknown Source)
	at org.jline.terminal.impl.jna.linux.LinuxNativePty.doSetAttr(LinuxNativePty.java:89)
	at org.jline.terminal.impl.AbstractPty.setAttr(AbstractPty.java:37)
	at org.jline.terminal.impl.AbstractPosixTerminal.setAttributes(AbstractPosixTerminal.java:52)
	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:730)
	at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:507)
	at org.apache.felix.gogo.jline.Shell.runShell(Shell.java:480)
	at org.apache.felix.gogo.jline.Shell.gosh(Shell.java:385)
	at org.apache.felix.gogo.jline.Main.main(Main.java:74)
Exception in thread "main" com.sun.jna.LastErrorException: [5] Input/output error
	at com.sun.jna.Native.invokeVoid(Native Method)
	at com.sun.jna.Function.invoke(Function.java:415)
	at com.sun.jna.Function.invoke(Function.java:361)
	at com.sun.jna.Library$Handler.invoke(Library.java:270)
	at com.sun.proxy.$Proxy0.tcsetattr(Unknown Source)
	at org.jline.terminal.impl.jna.linux.LinuxNativePty.doSetAttr(LinuxNativePty.java:89)
	at org.jline.terminal.impl.AbstractPty.setAttr(AbstractPty.java:37)
	at org.jline.terminal.impl.AbstractPosixTerminal.doClose(AbstractPosixTerminal.java:76)
	at org.jline.terminal.impl.PosixSysTerminal.doClose(PosixSysTerminal.java:95)
	at org.jline.terminal.impl.AbstractTerminal.close(AbstractTerminal.java:98)
	at org.apache.felix.gogo.jline.Main.main(Main.java:89)

@gnodet
Copy link
Member

gnodet commented Mar 7, 2023

@mattirn on my OSX platform, it prints a thread dump. I'll check on my linux VM.

@gnodet
Copy link
Member

gnodet commented Mar 7, 2023

Same on my linux VM when connecting through SSH.
@mattirn Can you report, the output of stty -a in your terminal ? Mine shows quit = ^\ which explains why it sends a QUIT signal.

@gnodet
Copy link
Member

gnodet commented Mar 7, 2023

On both my linux VM and OSX (M1), if I switch the key using stty quit "^]", and launching the gogo-repl demo on jna, jansi, and exec, everything works correctly: hitting ^] produces a thread dump and hitting ^\ does not do anything...

@gnodet
Copy link
Member

gnodet commented Mar 7, 2023

Fwiw, https://pubs.opengroup.org/onlinepubs/009604499/basedefs/xbd_chap11.html#tag_11_01_04 mentions the error EIO (which seems to be 5 / Input/output error on linux) to be returned in case of an orphaned process.

@mattirn
Copy link
Collaborator Author

mattirn commented Mar 7, 2023

Also I get thread dump and after it app crash with stacks shown above.

 % stty -a
speed 38400 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc

On Windows gitbash terminal Ctrl+\ when pressed first time print out thread dump and app do not crash. Subsequent Ctrl+\ do nothing.

@gnodet
Copy link
Member

gnodet commented Oct 24, 2023

@mattirn should we close that one ?

@mattirn
Copy link
Collaborator Author

mattirn commented Oct 25, 2023

@gnodet, yes I think we can close this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants