From d5a2ffec8cb6eb9ba820a1a758c4e2a51c0a20ab Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sat, 13 Feb 2021 14:43:27 +0100 Subject: [PATCH 1/2] explicitly open winpty conin pipe in write-only mode - fixes #457 --- src/windowsPtyAgent.ts | 9 +++++++-- src/windowsTerminal.test.ts | 10 ++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/windowsPtyAgent.ts b/src/windowsPtyAgent.ts index 3129b0a0..e46bfb1e 100644 --- a/src/windowsPtyAgent.ts +++ b/src/windowsPtyAgent.ts @@ -4,6 +4,7 @@ * Copyright (c) 2018, Microsoft Corporation (MIT License). */ +import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; import { Socket } from 'net'; @@ -126,9 +127,13 @@ export class WindowsPtyAgent { this._outSocket.emit('ready_datapipe'); }); - this._inSocket = new Socket(); + const inSocketFD = fs.openSync(term.conin, 'w'); + this._inSocket = new Socket({ + fd: inSocketFD, + readable: false, + writable: true + }); this._inSocket.setEncoding('utf8'); - this._inSocket.connect(term.conin); if (this._useConpty) { const connect = (this._ptyNative as IConptyNative).connect(this._pty, commandLine, cwd, env, c => this._$onProcessExit(c)); diff --git a/src/windowsTerminal.test.ts b/src/windowsTerminal.test.ts index 90441621..236327ec 100644 --- a/src/windowsTerminal.test.ts +++ b/src/windowsTerminal.test.ts @@ -201,5 +201,15 @@ if (process.platform === 'win32') { }); }); }); + + describe('winpty', () => { + it('should accept input', (done) => { + const term = new WindowsTerminal('cmd.exe', '', { useConpty: false }); + term.write('exit\r'); + term.on('exit', () => { + done(); + }); + }); + }); }); } From d26cba1bd4f9c6b8728ce22a09ff5c00272b7168 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 16 Feb 2021 02:33:29 -0800 Subject: [PATCH 2/2] Add Node 14 to CI --- azure-pipelines.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ca76c9a0..a2bfb184 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,6 +11,8 @@ jobs: matrix: node_12_x: node_version: 12.x + node_14_x: + node_version: 14.x steps: - task: NodeTool@0 inputs: @@ -33,6 +35,8 @@ jobs: matrix: node_12_x: node_version: 12.x + node_14_x: + node_version: 14.x steps: - task: NodeTool@0 inputs: @@ -55,6 +59,8 @@ jobs: matrix: node_12_x: node_version: 12.x + node_14_x: + node_version: 14.x steps: - task: NodeTool@0 inputs: