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

[Windows] Add support for ConPTY #947

Open
ExE-Boss opened this issue Mar 7, 2024 · 4 comments
Open

[Windows] Add support for ConPTY #947

ExE-Boss opened this issue Mar 7, 2024 · 4 comments

Comments

@ExE-Boss
Copy link
Contributor

ExE-Boss commented Mar 7, 2024

As of Windows 10, Windows now has the ConPTY API, which behaves similarly to the POSIX PTY APIs, making it possible to use real pseudoconsoles on Windows, without needing to use hacks like WinPTY, which spawn a hidden conhost session off‑screen and scrape its output.

Refs:

@jvalkeal
Copy link
Contributor

Afaik, there's no wintpy use in jline.

Having said that I was meant to ask @gnodet what it'd look like to add pty process support into jline? There is pty4j(uses conpty with fallback to winpty) from JetBrains but it has its own issues making it difficult to rely on.

It'd be quite nice feature to run external command with pty from jline based app. Something I've been looking to support in spring-shell but it feels a wrong place for code like this.

We could start by implementing these via ffm(jvm22+) and then look if there's any interest for supporting older jvm's via jni.

@gnodet
Copy link
Member

gnodet commented Apr 19, 2024

Afaik, there's no wintpy use in jline.

Right. When running in a windows console, JLine access the windows api to control it.

Having said that I was meant to ask @gnodet what it'd look like to add pty process support into jline? There is pty4j(uses conpty with fallback to winpty) from JetBrains but it has its own issues making it difficult to rely on.

It'd be quite nice feature to run external command with pty from jline based app. Something I've been looking to support in spring-shell but it feels a wrong place for code like this.

We could start by implementing these via ffm(jvm22+) and then look if there's any interest for supporting older jvm's via jni.

I'm not completely sure what you'd want to achieve here. For example, you have a JLine based app running in a console, and you want to launch a bash shell using the current terminal ? Or you want to create a pseudo terminal using JLine and then fork/exec a native process in it ?
The first part is already doable afaik. The second part is missing the fork/tcsetsid/execve call, as opening a pseudo terminal can already be done.

@jvalkeal
Copy link
Contributor

Yeah fork/execve, at least on linux, was what I meant. In a perfect world jdk's ProcessBuilder would do this, pty4j is trying to have pty features as extension named PtyProcessBuilder.

@gnodet
Copy link
Member

gnodet commented Apr 20, 2024

Yeah fork/execve, at least on linux, was what I meant. In a perfect world jdk's ProcessBuilder would do this, pty4j is trying to have pty features as extension named PtyProcessBuilder.

Ok. I think JLine could be a good location for this feature. Out of curiosity, what usage do you foresee for it ? The two implementations seem to come from Intelij IDEA and Eclipse so that they can run real terminals/shells inside the IDE. JLine is more oriented toward console mode application, so it's more unusual to spawn another terminal.

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

3 participants