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

Explicitly open winpty conin pipe in write-only mode - fixes #457 #460

Merged
merged 2 commits into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions src/windowsPtyAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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));
Expand Down
10 changes: 10 additions & 0 deletions src/windowsTerminal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
});
}