-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
proposal: os/exec,syscall: support running process on ConPty on Windows #62708
Comments
is there a specific change that you're proposing that could make it work? cc @golang/windows |
Yes, I just submitted #62710 to fix this issue |
This allows the user to pass a ConPty handle to run a process on a ConPty session. See: https://learn.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session Fixes: golang#62708
This allows the user to pass a ConPty handle to run a process on a ConPty session. See https://learn.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session Fixes golang#62708
Change https://go.dev/cl/529315 mentions this issue: |
This proposal doesn't contain the necessary API changes to support ConPty. For what I can see in the associated CL 529315, it would only need this addition into syscall.SysProcAttr : type SysProcAttr struct {
...
PseudoConsole Handle // if non-zero, the new process will be attached to the console represented by this handle, any AdditionalInheritedHandles will be ignored, this implies NoInheritHandles
} Reading the docs and peeking at some code samples out there, adding this new property seems like enough to creating pseudoconsole sessions. What I can't find is documentation about why it precludes inheriting additional handles. Could you help me understanding that? |
That's correct. This is where CL 528915 comes in place to add ConPty API to sys/windows. We need CL 529315 to support running processes on a ConPty.
I couldn't find any info in the docs. All I found is this comment from hcsshim "If the client requested a pseudo console then there's nothing we need to do pipe wise, as the process inherits the other end of the pty's pipes." EDIT: add node-pty and microsoft/node-pty#334 for reference |
Thanks for the sources. What I understood is that ConPty has a bug that makes it misbehave when inheriting handles. As it makes no sense to do that anyway, then handle inheriting is disabled. Looks fuzzy, but convinced me. |
Any updates on this one? #62710 CR 529315 only needs one addition to type SysProcAttr struct {
...
PseudoConsole Handle // if non-zero, the new process will be attached to the console represented by this handle, any AdditionalInheritedHandles will be ignored, this implies NoInheritHandles
} |
It still needs to complete the proposal process and get accepted. The next step is that this proposal is discussed by the proposals team, but it can take a while as the proposals queue is big. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Windows now supports creating pseudo consoles, ConPty, using their Console API. As of now, we cannot run a process on a ConPty using
os/exec
. That's due to the fact that ConPty requires updating the process attributes with the Pty handle and pseudoconsole attribute (PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE = 0x00020016
), and currently, there is no way to pass the Pty handle down tosyscall.StartProcess
.See: https://learn.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session
Related: golang/sys#175
What did you expect to see?
The process runs on a ConPty session.
What did you see instead?
The process does not run on a ConPty session.
The text was updated successfully, but these errors were encountered: