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

Can't Execute Bash Via JLine in Windows Command Prompt #193

Closed
cjohnstoniv opened this issue Nov 27, 2017 · 5 comments
Closed

Can't Execute Bash Via JLine in Windows Command Prompt #193

cjohnstoniv opened this issue Nov 27, 2017 · 5 comments

Comments

@cjohnstoniv
Copy link

cjohnstoniv commented Nov 27, 2017

In JLine 2 I was able to execute the below code and everything besides SIGNALS worked with underlying BASH command in Windows CMD Prompt. When I say everything worked, I mean keyboard input was passed through correctly to the bash terminal when inheritIO is set.

ProcessBuilder pb = new ProcessBuilder("pathToCygwin/bin/bash.exe", "--login", "-i");
pb.inheritIO();
Process process = pb.start();
//Wait for process to finish

However with JLine 3 the above code almost always results in the entire CMD prompt window becoming "frozen". It's not really frozen as I can still copy test however the keyboard input does not get piped to the running BASH command as did in JLine 2. Sometimes (rarely) when I run it though my keyboard input does get redirected to the BASH command. Is there anyway to do this with Jline 3?

Basically just want to be able to launch BASH.exe (with --login and -i) from a JLine 3 shell for convenience instead of having to exit the JLine app to access BASH.

@gnodet
Copy link
Member

gnodet commented Dec 19, 2017

This looks similar to #169 which has been fixed by gnodet@f8eda07.

@cjohnstoniv
Copy link
Author

Unfortunately I am still seeing this issue. The simple code snippet below (running in Java 8/9 in CMD Prompt) results in Cygwin opening, and showing me its normal prompt. But most of my key presses don't make it to the Cygwin input (at least they aren't displayed in the window). If I type really quickly I can see some my keypresses but most are missing.

final Terminal terminal = TerminalBuilder.builder().system(true).build(); new ProcessBuilder("cmd.exe", "/C", "[path to cygwin]/cygwin/bin/bash.exe", "--login").inheritIO().start().waitFor();

If I comment out the first Terminal line (i.e. don't build a terminal) the app works as expected. So something with the terminal is catching these keys and not properly passing them down. I'll have some bandwidth coming up with the holidays, if you can point to some places you think might the be the cause / give me some pointers on how to debug this, I can take a look as well.

@gnodet
Copy link
Member

gnodet commented Dec 21, 2017

Yes, you missed the part where the Terminal has to be closed in order for the streams to be restored completely.
With JLine3, some terminals do continuously read the input stream in order to process signals. This can't be stopped currently, unless you close the Terminal. See #140 and #141.

@cjohnstoniv
Copy link
Author

cjohnstoniv commented Dec 21, 2017

Ah I see, apologies for missing that note. Closing the terminal before inheriting the IO solved it!

"This can't be stopped currently, unless you close the Terminal", were you planning to implement a feature to stop the stream reading temporarily without closing the whole terminal? If you have any details/spec I can try to implement for you.

Thanks again for your help!

@gnodet
Copy link
Member

gnodet commented Dec 21, 2017

This is captured in #140 which has an initial work in progress PR attached to it. If you want to have a look, feel free to do so, that would be awesome !

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

No branches or pull requests

2 participants