forked from nodejs/node-v0.x-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtty.js
More file actions
38 lines (24 loc) · 732 Bytes
/
tty.js
File metadata and controls
38 lines (24 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var spawn = require('child_process').spawn;
var binding = process.binding('stdio');
exports.isatty = binding.isatty;
exports.setRawMode = binding.setRawMode;
exports.getWindowSize = binding.getWindowSize;
exports.setWindowSize = binding.setWindowSize;
exports.open = function(path, args) {
var fds = binding.openpty();
var slaveFD = fds[0];
var masterFD = fds[1];
var env = { TERM: 'vt100' };
for (var k in process.env) {
env[k] = process.env[k];
}
var stream = require('net').Stream(slaveFD);
stream.readable = stream.writable = true;
stream.resume();
child = spawn(path, args, {
env: env,
customFds: [masterFD, masterFD, masterFD],
setuid: true
});
return [stream, child];
};