Skip to content

Commit 50e3fec

Browse files
committed
More detail about closing pseudoconsole on windows
Signed-off-by: Spike Curtis <spike@coder.com>
1 parent df424e6 commit 50e3fec

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pty/pty_windows.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ func (p *ptyWindows) Close() error {
169169
func (p *windowsProcess) waitInternal() {
170170
defer func() {
171171
// close the pseudoconsole handle when the process exits, if it hasn't already been closed.
172+
// this is important because the PseudoConsole (conhost.exe) holds the write-end
173+
// of the output pipe. If it is not closed, reads on that pipe will block, even though
174+
// the command has exited.
175+
// c.f. https://devblogs.microsoft.com/commandline/windows-command-line-introducing-the-windows-pseudo-console-conpty/
172176
p.pw.closeMutex.Lock()
173177
defer p.pw.closeMutex.Unlock()
174178
if p.pw.console != windows.InvalidHandle {

0 commit comments

Comments
 (0)