node-pty 1.2.0-beta.7 → 1.2.0-beta.8
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/binding.gyp +20 -18
- package/package.json +6 -5
- package/prebuilds/darwin-arm64/pty.node +0 -0
- package/prebuilds/darwin-arm64/spawn-helper +0 -0
- package/prebuilds/darwin-x64/pty.node +0 -0
- package/prebuilds/darwin-x64/spawn-helper +0 -0
- package/prebuilds/win32-arm64/conpty.node +0 -0
- package/prebuilds/win32-arm64/conpty.pdb +0 -0
- package/prebuilds/win32-arm64/conpty_console_list.node +0 -0
- package/prebuilds/win32-arm64/conpty_console_list.pdb +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
- package/deps/.editorconfig +0 -2
- package/lib/conpty_console_list_agent.js.map +0 -1
- package/lib/eventEmitter2.js.map +0 -1
- package/lib/eventEmitter2.test.js +0 -30
- package/lib/eventEmitter2.test.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interfaces.js.map +0 -1
- package/lib/shared/conout.js.map +0 -1
- package/lib/terminal.js.map +0 -1
- package/lib/terminal.test.js +0 -139
- package/lib/terminal.test.js.map +0 -1
- package/lib/testUtils.test.js +0 -28
- package/lib/testUtils.test.js.map +0 -1
- package/lib/types.js.map +0 -1
- package/lib/unixTerminal.js.map +0 -1
- package/lib/unixTerminal.test.js +0 -383
- package/lib/unixTerminal.test.js.map +0 -1
- package/lib/utils.js.map +0 -1
- package/lib/windowsConoutConnection.js.map +0 -1
- package/lib/windowsPtyAgent.js.map +0 -1
- package/lib/windowsPtyAgent.test.js +0 -90
- package/lib/windowsPtyAgent.test.js.map +0 -1
- package/lib/windowsTerminal.js.map +0 -1
- package/lib/windowsTerminal.test.js +0 -218
- package/lib/windowsTerminal.test.js.map +0 -1
- package/lib/worker/conoutSocketWorker.js.map +0 -1
- package/scripts/gen-compile-commands.js +0 -8
- package/scripts/increment-version.js +0 -54
- package/scripts/linux/checksums.txt +0 -2
- package/scripts/linux/install-sysroot.js +0 -158
- package/scripts/linux/verify-glibc-requirements.sh +0 -36
- package/src/conpty_console_list_agent.ts +0 -15
- package/src/eventEmitter2.test.ts +0 -30
- package/src/eventEmitter2.ts +0 -48
- package/src/index.ts +0 -52
- package/src/interfaces.ts +0 -138
- package/src/native.d.ts +0 -37
- package/src/shared/conout.ts +0 -15
- package/src/terminal.test.ts +0 -119
- package/src/terminal.ts +0 -211
- package/src/testUtils.test.ts +0 -23
- package/src/tsconfig.json +0 -22
- package/src/types.ts +0 -15
- package/src/unixTerminal.test.ts +0 -402
- package/src/unixTerminal.ts +0 -388
- package/src/utils.ts +0 -29
- package/src/windowsConoutConnection.ts +0 -82
- package/src/windowsPtyAgent.test.ts +0 -94
- package/src/windowsPtyAgent.ts +0 -261
- package/src/windowsTerminal.test.ts +0 -229
- package/src/windowsTerminal.ts +0 -203
- package/src/worker/conoutSocketWorker.ts +0 -22
package/src/unixTerminal.test.ts
DELETED
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017, Daniel Imms (MIT License).
|
|
3
|
-
* Copyright (c) 2018, Microsoft Corporation (MIT License).
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import * as assert from 'assert';
|
|
7
|
-
import * as cp from 'child_process';
|
|
8
|
-
import * as path from 'path';
|
|
9
|
-
import * as tty from 'tty';
|
|
10
|
-
import * as fs from 'fs';
|
|
11
|
-
import { constants } from 'os';
|
|
12
|
-
import { pollUntil } from './testUtils.test';
|
|
13
|
-
import { pid } from 'process';
|
|
14
|
-
import type { UnixTerminal as UnixTerminalType } from './unixTerminal';
|
|
15
|
-
|
|
16
|
-
const FIXTURES_PATH = path.normalize(path.join(__dirname, '..', 'fixtures', 'utf8-character.txt'));
|
|
17
|
-
|
|
18
|
-
if (process.platform !== 'win32') {
|
|
19
|
-
// Dynamic require to avoid loading pty.node on Windows
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
21
|
-
const { UnixTerminal } = require('./unixTerminal') as { UnixTerminal: typeof UnixTerminalType };
|
|
22
|
-
|
|
23
|
-
describe('UnixTerminal', () => {
|
|
24
|
-
describe('Constructor', () => {
|
|
25
|
-
it('should set a valid pts name', () => {
|
|
26
|
-
const term = new UnixTerminal('/bin/bash', [], {});
|
|
27
|
-
let regExp: RegExp | undefined;
|
|
28
|
-
if (process.platform === 'linux') {
|
|
29
|
-
// https://linux.die.net/man/4/pts
|
|
30
|
-
regExp = /^\/dev\/pts\/\d+$/;
|
|
31
|
-
}
|
|
32
|
-
if (process.platform === 'darwin') {
|
|
33
|
-
// https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man4/pty.4.html
|
|
34
|
-
regExp = /^\/dev\/tty[p-sP-S][a-z0-9]+$/;
|
|
35
|
-
}
|
|
36
|
-
if (regExp) {
|
|
37
|
-
assert.ok(regExp.test(term.ptsName), '"' + term.ptsName + '" should match ' + regExp.toString());
|
|
38
|
-
}
|
|
39
|
-
assert.ok(tty.isatty(term.fd));
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe('PtyForkEncodingOption', () => {
|
|
44
|
-
it('should default to utf8', (done) => {
|
|
45
|
-
const term = new UnixTerminal('/bin/bash', [ '-c', `cat "${FIXTURES_PATH}"` ]);
|
|
46
|
-
term.on('data', (data) => {
|
|
47
|
-
assert.strictEqual(typeof data, 'string');
|
|
48
|
-
assert.strictEqual(data, '\u00E6');
|
|
49
|
-
done();
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
it('should return a Buffer when encoding is null', (done) => {
|
|
53
|
-
const term = new UnixTerminal('/bin/bash', [ '-c', `cat "${FIXTURES_PATH}"` ], {
|
|
54
|
-
encoding: null
|
|
55
|
-
});
|
|
56
|
-
term.on('data', (data) => {
|
|
57
|
-
assert.strictEqual(typeof data, 'object');
|
|
58
|
-
assert.ok(data instanceof Buffer);
|
|
59
|
-
assert.strictEqual(0xC3, data[0]);
|
|
60
|
-
assert.strictEqual(0xA6, data[1]);
|
|
61
|
-
done();
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
it('should support other encodings', (done) => {
|
|
65
|
-
const text = 'test æ!';
|
|
66
|
-
const term = new UnixTerminal(undefined, ['-c', 'echo "' + text + '"'], {
|
|
67
|
-
encoding: 'base64'
|
|
68
|
-
});
|
|
69
|
-
let buffer = '';
|
|
70
|
-
term.onData((data) => {
|
|
71
|
-
assert.strictEqual(typeof data, 'string');
|
|
72
|
-
buffer += data;
|
|
73
|
-
});
|
|
74
|
-
term.onExit(() => {
|
|
75
|
-
assert.strictEqual(Buffer.alloc(8, buffer, 'base64').toString().replace('\r', '').replace('\n', ''), text);
|
|
76
|
-
done();
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
describe('open', () => {
|
|
82
|
-
let term: UnixTerminalType;
|
|
83
|
-
|
|
84
|
-
afterEach(() => {
|
|
85
|
-
if (term) {
|
|
86
|
-
term.slave!.destroy();
|
|
87
|
-
term.master!.destroy();
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('should open a pty with access to a master and slave socket', (done) => {
|
|
92
|
-
term = UnixTerminal.open({});
|
|
93
|
-
|
|
94
|
-
let slavebuf = '';
|
|
95
|
-
term.slave!.on('data', (data) => {
|
|
96
|
-
slavebuf += data;
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
let masterbuf = '';
|
|
100
|
-
term.master!.on('data', (data) => {
|
|
101
|
-
masterbuf += data;
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
pollUntil(() => {
|
|
105
|
-
if (masterbuf === 'slave\r\nmaster\r\n' && slavebuf === 'master\n') {
|
|
106
|
-
done();
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
return false;
|
|
110
|
-
}, 200, 10);
|
|
111
|
-
|
|
112
|
-
term.slave!.write('slave\n');
|
|
113
|
-
term.master!.write('master\n');
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
describe('close', () => {
|
|
117
|
-
const term = new UnixTerminal('node');
|
|
118
|
-
it('should exit when terminal is destroyed programmatically', (done) => {
|
|
119
|
-
term.on('exit', (code, signal) => {
|
|
120
|
-
assert.strictEqual(code, 0);
|
|
121
|
-
assert.strictEqual(signal, constants.signals.SIGHUP);
|
|
122
|
-
done();
|
|
123
|
-
});
|
|
124
|
-
term.destroy();
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
describe('signals in parent and child', () => {
|
|
128
|
-
it('SIGINT - custom in parent and child', done => {
|
|
129
|
-
// this test is cumbersome - we have to run it in a sub process to
|
|
130
|
-
// see behavior of SIGINT handlers
|
|
131
|
-
const data = `
|
|
132
|
-
var pty = require('./lib/index');
|
|
133
|
-
process.on('SIGINT', () => console.log('SIGINT in parent'));
|
|
134
|
-
var ptyProcess = pty.spawn('node', ['-e', 'process.on("SIGINT", ()=>console.log("SIGINT in child"));setTimeout(() => null, 300);'], {
|
|
135
|
-
name: 'xterm-color',
|
|
136
|
-
cols: 80,
|
|
137
|
-
rows: 30,
|
|
138
|
-
cwd: process.env.HOME,
|
|
139
|
-
env: process.env
|
|
140
|
-
});
|
|
141
|
-
ptyProcess.on('data', function (data) {
|
|
142
|
-
console.log(data);
|
|
143
|
-
});
|
|
144
|
-
setTimeout(() => null, 500);
|
|
145
|
-
console.log('ready', ptyProcess.pid);
|
|
146
|
-
`;
|
|
147
|
-
const buffer: string[] = [];
|
|
148
|
-
const p = cp.spawn('node', ['-e', data]);
|
|
149
|
-
let sub = '';
|
|
150
|
-
p.stdout.on('data', (data) => {
|
|
151
|
-
if (!data.toString().indexOf('ready')) {
|
|
152
|
-
sub = data.toString().split(' ')[1].slice(0, -1);
|
|
153
|
-
setTimeout(() => {
|
|
154
|
-
process.kill(parseInt(sub), 'SIGINT'); // SIGINT to child
|
|
155
|
-
p.kill('SIGINT'); // SIGINT to parent
|
|
156
|
-
}, 200);
|
|
157
|
-
} else {
|
|
158
|
-
buffer.push(data.toString().replace(/^\s+|\s+$/g, ''));
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
p.on('close', () => {
|
|
162
|
-
// handlers in parent and child should have been triggered
|
|
163
|
-
assert.strictEqual(buffer.indexOf('SIGINT in child') !== -1, true);
|
|
164
|
-
assert.strictEqual(buffer.indexOf('SIGINT in parent') !== -1, true);
|
|
165
|
-
done();
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
it('SIGINT - custom in parent, default in child', done => {
|
|
169
|
-
// this tests the original idea of the signal(...) change in pty.cc:
|
|
170
|
-
// to make sure the SIGINT handler of a pty child is reset to default
|
|
171
|
-
// and does not interfere with the handler in the parent
|
|
172
|
-
const data = `
|
|
173
|
-
var pty = require('./lib/index');
|
|
174
|
-
process.on('SIGINT', () => console.log('SIGINT in parent'));
|
|
175
|
-
var ptyProcess = pty.spawn('node', ['-e', 'setTimeout(() => console.log("should not be printed"), 300);'], {
|
|
176
|
-
name: 'xterm-color',
|
|
177
|
-
cols: 80,
|
|
178
|
-
rows: 30,
|
|
179
|
-
cwd: process.env.HOME,
|
|
180
|
-
env: process.env
|
|
181
|
-
});
|
|
182
|
-
ptyProcess.on('data', function (data) {
|
|
183
|
-
console.log(data);
|
|
184
|
-
});
|
|
185
|
-
setTimeout(() => null, 500);
|
|
186
|
-
console.log('ready', ptyProcess.pid);
|
|
187
|
-
`;
|
|
188
|
-
const buffer: string[] = [];
|
|
189
|
-
const p = cp.spawn('node', ['-e', data]);
|
|
190
|
-
let sub = '';
|
|
191
|
-
p.stdout.on('data', (data) => {
|
|
192
|
-
if (!data.toString().indexOf('ready')) {
|
|
193
|
-
sub = data.toString().split(' ')[1].slice(0, -1);
|
|
194
|
-
setTimeout(() => {
|
|
195
|
-
process.kill(parseInt(sub), 'SIGINT'); // SIGINT to child
|
|
196
|
-
p.kill('SIGINT'); // SIGINT to parent
|
|
197
|
-
}, 200);
|
|
198
|
-
} else {
|
|
199
|
-
buffer.push(data.toString().replace(/^\s+|\s+$/g, ''));
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
p.on('close', () => {
|
|
203
|
-
// handlers in parent and child should have been triggered
|
|
204
|
-
assert.strictEqual(buffer.indexOf('should not be printed') !== -1, false);
|
|
205
|
-
assert.strictEqual(buffer.indexOf('SIGINT in parent') !== -1, true);
|
|
206
|
-
done();
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
it('SIGHUP default (child only)', done => {
|
|
210
|
-
const term = new UnixTerminal('node', [ '-e', `
|
|
211
|
-
console.log('ready');
|
|
212
|
-
setTimeout(()=>console.log('timeout'), 200);`
|
|
213
|
-
]);
|
|
214
|
-
let buffer = '';
|
|
215
|
-
term.on('data', (data) => {
|
|
216
|
-
if (data === 'ready\r\n') {
|
|
217
|
-
term.kill();
|
|
218
|
-
} else {
|
|
219
|
-
buffer += data;
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
term.on('exit', () => {
|
|
223
|
-
// no timeout in buffer
|
|
224
|
-
assert.strictEqual(buffer, '');
|
|
225
|
-
done();
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
it('SIGUSR1 - custom in parent and child', done => {
|
|
229
|
-
let pHandlerCalled = 0;
|
|
230
|
-
const handleSigUsr = function(h: any): any {
|
|
231
|
-
return function(): void {
|
|
232
|
-
pHandlerCalled += 1;
|
|
233
|
-
process.removeListener('SIGUSR1', h);
|
|
234
|
-
};
|
|
235
|
-
};
|
|
236
|
-
process.on('SIGUSR1', handleSigUsr(handleSigUsr));
|
|
237
|
-
|
|
238
|
-
const term = new UnixTerminal('node', [ '-e', `
|
|
239
|
-
process.on('SIGUSR1', () => {
|
|
240
|
-
console.log('SIGUSR1 in child');
|
|
241
|
-
});
|
|
242
|
-
console.log('ready');
|
|
243
|
-
setTimeout(()=>null, 200);`
|
|
244
|
-
]);
|
|
245
|
-
let buffer = '';
|
|
246
|
-
term.on('data', (data) => {
|
|
247
|
-
if (data === 'ready\r\n') {
|
|
248
|
-
process.kill(process.pid, 'SIGUSR1');
|
|
249
|
-
term.kill('SIGUSR1');
|
|
250
|
-
} else {
|
|
251
|
-
buffer += data;
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
term.on('exit', () => {
|
|
255
|
-
// should have called both handlers and only once
|
|
256
|
-
assert.strictEqual(pHandlerCalled, 1);
|
|
257
|
-
assert.strictEqual(buffer, 'SIGUSR1 in child\r\n');
|
|
258
|
-
done();
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
describe('spawn', () => {
|
|
263
|
-
if (process.platform === 'linux') {
|
|
264
|
-
it('should not leak pty file descriptors to child processes', (done) => {
|
|
265
|
-
// Spawn 3 ptys - the 3rd should not see FDs from the first two
|
|
266
|
-
const ptys: UnixTerminalType[] = [];
|
|
267
|
-
for (let i = 0; i < 3; i++) {
|
|
268
|
-
ptys.push(new UnixTerminal('/bin/bash', [], {}));
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
let output = '';
|
|
272
|
-
ptys[2].onData((data) => {
|
|
273
|
-
output += data;
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
// Check for ptmx FDs in the 3rd terminal's shell
|
|
277
|
-
ptys[2].write('echo "PTMX_COUNT:$(file /proc/$$/fd/* 2>/dev/null | grep -c ptmx)"\n');
|
|
278
|
-
|
|
279
|
-
setTimeout(() => {
|
|
280
|
-
for (const pty of ptys) {
|
|
281
|
-
pty.kill();
|
|
282
|
-
}
|
|
283
|
-
// Extract the count from output - should be 0
|
|
284
|
-
const match = output.match(/PTMX_COUNT:(\d+)/);
|
|
285
|
-
assert.ok(match, `Could not find PTMX_COUNT in output: ${output}`);
|
|
286
|
-
assert.strictEqual(match![1], '0', `Expected 0 ptmx FDs but got ${match![1]}`);
|
|
287
|
-
done();
|
|
288
|
-
}, 1000);
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
if (process.platform === 'darwin') {
|
|
292
|
-
it('should return the name of the process', (done) => {
|
|
293
|
-
const term = new UnixTerminal('/bin/echo');
|
|
294
|
-
assert.strictEqual(term.process, '/bin/echo');
|
|
295
|
-
term.on('exit', () => done());
|
|
296
|
-
term.destroy();
|
|
297
|
-
});
|
|
298
|
-
it('should return the name of the sub process', (done) => {
|
|
299
|
-
const data = `
|
|
300
|
-
var pty = require('./lib/index');
|
|
301
|
-
var ptyProcess = pty.spawn('zsh', ['-c', 'python3'], {
|
|
302
|
-
env: process.env
|
|
303
|
-
});
|
|
304
|
-
ptyProcess.on('data', function (data) {
|
|
305
|
-
if (ptyProcess.process === 'Python') {
|
|
306
|
-
console.log('title', ptyProcess.process);
|
|
307
|
-
console.log('ready', ptyProcess.pid);
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
`;
|
|
311
|
-
const p = cp.spawn('node', ['-e', data]);
|
|
312
|
-
let sub = '';
|
|
313
|
-
let pid = '';
|
|
314
|
-
p.stdout.on('data', (data) => {
|
|
315
|
-
const lines = data.toString().split('\n');
|
|
316
|
-
for (const line of lines) {
|
|
317
|
-
if (line.startsWith('title ')) {
|
|
318
|
-
sub = line.split(' ')[1];
|
|
319
|
-
} else if (line.startsWith('ready ')) {
|
|
320
|
-
pid = line.split(' ')[1];
|
|
321
|
-
process.kill(parseInt(pid), 'SIGINT');
|
|
322
|
-
p.kill('SIGINT');
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
p.on('exit', () => {
|
|
327
|
-
assert.notStrictEqual(pid, '');
|
|
328
|
-
assert.strictEqual(sub, 'Python');
|
|
329
|
-
done();
|
|
330
|
-
});
|
|
331
|
-
});
|
|
332
|
-
it('should close on exec', (done) => {
|
|
333
|
-
const data = `
|
|
334
|
-
var pty = require('./lib/index');
|
|
335
|
-
var ptyProcess = pty.spawn('node', ['-e', 'setTimeout(() => console.log("hello from terminal"), 300);']);
|
|
336
|
-
ptyProcess.on('data', function (data) {
|
|
337
|
-
console.log(data);
|
|
338
|
-
});
|
|
339
|
-
setTimeout(() => null, 500);
|
|
340
|
-
console.log('ready', ptyProcess.pid);
|
|
341
|
-
`;
|
|
342
|
-
const buffer: string[] = [];
|
|
343
|
-
const readFd = fs.openSync(FIXTURES_PATH, 'r');
|
|
344
|
-
const p = cp.spawn('node', ['-e', data], {
|
|
345
|
-
stdio: ['ignore', 'pipe', 'pipe', readFd]
|
|
346
|
-
});
|
|
347
|
-
let sub = '';
|
|
348
|
-
p.stdout!.on('data', (data) => {
|
|
349
|
-
if (!data.toString().indexOf('ready')) {
|
|
350
|
-
sub = data.toString().split(' ')[1].slice(0, -1);
|
|
351
|
-
try {
|
|
352
|
-
fs.statSync(`/proc/${sub}/fd/${readFd}`);
|
|
353
|
-
done('not reachable');
|
|
354
|
-
} catch (error) {
|
|
355
|
-
assert.notStrictEqual((error as NodeJS.ErrnoException).message.indexOf('ENOENT'), -1);
|
|
356
|
-
}
|
|
357
|
-
setTimeout(() => {
|
|
358
|
-
process.kill(parseInt(sub), 'SIGINT'); // SIGINT to child
|
|
359
|
-
p.kill('SIGINT'); // SIGINT to parent
|
|
360
|
-
}, 200);
|
|
361
|
-
} else {
|
|
362
|
-
buffer.push(data.toString().replace(/^\s+|\s+$/g, ''));
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
p.on('close', () => {
|
|
366
|
-
done();
|
|
367
|
-
});
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
it('should handle exec() errors', (done) => {
|
|
371
|
-
const term = new UnixTerminal('/bin/bogus.exe', []);
|
|
372
|
-
term.on('exit', (code, signal) => {
|
|
373
|
-
assert.strictEqual(code, 1);
|
|
374
|
-
done();
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
it('should handle chdir() errors', (done) => {
|
|
378
|
-
const term = new UnixTerminal('/bin/echo', [], { cwd: '/nowhere' });
|
|
379
|
-
term.on('exit', (code, signal) => {
|
|
380
|
-
assert.strictEqual(code, 1);
|
|
381
|
-
done();
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
it('should not leak child process', (done) => {
|
|
385
|
-
const count = cp.execSync('ps -ax | grep node | wc -l');
|
|
386
|
-
const term = new UnixTerminal('node', [ '-e', `
|
|
387
|
-
console.log('ready');
|
|
388
|
-
setTimeout(()=>console.log('timeout'), 200);`
|
|
389
|
-
]);
|
|
390
|
-
term.on('data', async (data) => {
|
|
391
|
-
if (data === 'ready\r\n') {
|
|
392
|
-
process.kill(term.pid, 'SIGINT');
|
|
393
|
-
await setTimeout(() => null, 1000);
|
|
394
|
-
const newCount = cp.execSync('ps -ax | grep node | wc -l');
|
|
395
|
-
assert.strictEqual(count.toString(), newCount.toString());
|
|
396
|
-
done();
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
});
|
|
402
|
-
}
|