@lydell/node-pty-win32-x64 1.2.0-beta.10 → 1.2.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/conpty_console_list_agent.js +10 -1
- package/lib/windowsPtyAgent.js +32 -2
- package/lib/windowsTerminal.js +2 -0
- package/package.json +1 -1
- package/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
- package/prebuilds/win32-x64/conpty/conpty.dll +0 -0
- package/prebuilds/win32-x64/conpty.node +0 -0
- package/prebuilds/win32-x64/conpty.pdb +0 -0
- package/prebuilds/win32-x64/conpty_console_list.node +0 -0
- package/prebuilds/win32-x64/conpty_console_list.pdb +0 -0
|
@@ -10,7 +10,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
var utils_1 = require("./utils");
|
|
11
11
|
var getConsoleProcessList = utils_1.loadNativeModule('conpty_console_list').module.getConsoleProcessList;
|
|
12
12
|
var shellPid = parseInt(process.argv[2], 10);
|
|
13
|
-
var consoleProcessList =
|
|
13
|
+
var consoleProcessList = [];
|
|
14
|
+
if (shellPid > 0) {
|
|
15
|
+
try {
|
|
16
|
+
consoleProcessList = getConsoleProcessList(shellPid);
|
|
17
|
+
}
|
|
18
|
+
catch (_a) {
|
|
19
|
+
// AttachConsole can fail if the process already exited or is invalid.
|
|
20
|
+
consoleProcessList = [];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
14
23
|
process.send({ consoleProcessList: consoleProcessList });
|
|
15
24
|
process.exit(0);
|
|
16
25
|
//# sourceMappingURL=conpty_console_list_agent.js.map
|
package/lib/windowsPtyAgent.js
CHANGED
|
@@ -48,9 +48,26 @@ var WindowsPtyAgent = /** @class */ (function () {
|
|
|
48
48
|
this._outSocket = new net_1.Socket();
|
|
49
49
|
this._outSocket.setEncoding('utf8');
|
|
50
50
|
// The conout socket must be ready out on another thread to avoid deadlocks
|
|
51
|
+
// We must wait for the worker to connect before calling conptyNative.connect()
|
|
52
|
+
// to avoid blocking the Node.js event loop in ConnectNamedPipe.
|
|
53
|
+
// See https://github.com/microsoft/node-pty/issues/763
|
|
51
54
|
this._conoutSocketWorker = new windowsConoutConnection_1.ConoutConnection(term.conout, this._useConptyDll);
|
|
55
|
+
// Store pending connection info - we'll complete the connection when worker is ready
|
|
56
|
+
this._pendingPtyInfo = { pty: this._pty, commandLine: commandLine, cwd: cwd, env: env };
|
|
57
|
+
// Timeout to ensure connection completes even if worker fails to signal ready
|
|
58
|
+
var connectionTimeout = setTimeout(function () {
|
|
59
|
+
if (_this._pendingPtyInfo) {
|
|
60
|
+
// Worker never signaled ready - complete connection anyway to avoid zombie state
|
|
61
|
+
_this._completePtyConnection();
|
|
62
|
+
}
|
|
63
|
+
}, 5000);
|
|
52
64
|
this._conoutSocketWorker.onReady(function () {
|
|
65
|
+
clearTimeout(connectionTimeout);
|
|
53
66
|
_this._conoutSocketWorker.connectSocket(_this._outSocket);
|
|
67
|
+
// Now that the worker has connected to the output pipe, we can safely call
|
|
68
|
+
// conptyNative.connect() which calls ConnectNamedPipe - it won't block because
|
|
69
|
+
// the client (worker) is already connected
|
|
70
|
+
_this._completePtyConnection();
|
|
54
71
|
});
|
|
55
72
|
this._outSocket.on('connect', function () {
|
|
56
73
|
_this._outSocket.emit('ready_datapipe');
|
|
@@ -62,8 +79,6 @@ var WindowsPtyAgent = /** @class */ (function () {
|
|
|
62
79
|
writable: true
|
|
63
80
|
});
|
|
64
81
|
this._inSocket.setEncoding('utf8');
|
|
65
|
-
var connect = conptyNative.connect(this._pty, commandLine, cwd, env, this._useConptyDll, function (c) { return _this._$onProcessExit(c); });
|
|
66
|
-
this._innerPid = connect.pid;
|
|
67
82
|
}
|
|
68
83
|
Object.defineProperty(WindowsPtyAgent.prototype, "inSocket", {
|
|
69
84
|
get: function () { return this._inSocket; },
|
|
@@ -90,6 +105,16 @@ var WindowsPtyAgent = /** @class */ (function () {
|
|
|
90
105
|
enumerable: false,
|
|
91
106
|
configurable: true
|
|
92
107
|
});
|
|
108
|
+
WindowsPtyAgent.prototype._completePtyConnection = function () {
|
|
109
|
+
var _this = this;
|
|
110
|
+
if (!this._pendingPtyInfo) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
var _a = this._pendingPtyInfo, pty = _a.pty, commandLine = _a.commandLine, cwd = _a.cwd, env = _a.env;
|
|
114
|
+
this._pendingPtyInfo = undefined;
|
|
115
|
+
var connect = conptyNative.connect(pty, commandLine, cwd, env, this._useConptyDll, function (c) { return _this._$onProcessExit(c); });
|
|
116
|
+
this._innerPid = connect.pid;
|
|
117
|
+
};
|
|
93
118
|
WindowsPtyAgent.prototype.resize = function (cols, rows) {
|
|
94
119
|
if (this._exitCode !== undefined) {
|
|
95
120
|
throw new Error('Cannot resize a pty that has already exited');
|
|
@@ -101,6 +126,8 @@ var WindowsPtyAgent = /** @class */ (function () {
|
|
|
101
126
|
};
|
|
102
127
|
WindowsPtyAgent.prototype.kill = function () {
|
|
103
128
|
var _this = this;
|
|
129
|
+
// Prevent deferred connection from completing after kill
|
|
130
|
+
this._pendingPtyInfo = undefined;
|
|
104
131
|
// Tell the agent to kill the pty, this releases handles to the process
|
|
105
132
|
if (!this._useConptyDll) {
|
|
106
133
|
this._inSocket.readable = false;
|
|
@@ -129,6 +156,9 @@ var WindowsPtyAgent = /** @class */ (function () {
|
|
|
129
156
|
};
|
|
130
157
|
WindowsPtyAgent.prototype._getConsoleProcessList = function () {
|
|
131
158
|
var _this = this;
|
|
159
|
+
if (this._innerPid <= 0) {
|
|
160
|
+
return Promise.resolve([]);
|
|
161
|
+
}
|
|
132
162
|
return new Promise(function (resolve) {
|
|
133
163
|
var agent = child_process_1.fork(path.join(__dirname, 'conpty_console_list_agent'), [_this._innerPid.toString()]);
|
|
134
164
|
agent.on('message', function (message) {
|
package/lib/windowsTerminal.js
CHANGED
|
@@ -57,6 +57,8 @@ var WindowsTerminal = /** @class */ (function (_super) {
|
|
|
57
57
|
// The forked windows terminal is not available until `ready` event is
|
|
58
58
|
// emitted.
|
|
59
59
|
_this._socket.on('ready_datapipe', function () {
|
|
60
|
+
// Update pid now that the agent has connected
|
|
61
|
+
_this._pid = _this._agent.innerPid;
|
|
60
62
|
// Run deferreds and set ready state once the first data event is received.
|
|
61
63
|
_this._socket.once('data', function () {
|
|
62
64
|
// Wait until the first data event is fired then we can run deferreds.
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|