Skip to content

proposal: os/exec,syscall: support running process on ConPty on Windows #62708

Open
@aymanbagabas

Description

@aymanbagabas

What version of Go are you using (go version)?

$ go version
go version go1.21.1 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Ayman\AppData\Local\go-build
set GOENV=C:\Users\Ayman\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Ayman\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Ayman\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.1
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\Ayman\AppData\Local\Temp\go-build1093290718=/tmp/go-build -gno-record-gcc-switches

What 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 to syscall.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.OS-WindowsProposalcompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    No status

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions