-
Notifications
You must be signed in to change notification settings - Fork 19
/
qemu.js
50 lines (36 loc) · 1.01 KB
/
qemu.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
var sub = require('./lib/comm').receiver('qemu-manager');
console.log('Connecting to master...');
sub.monitor();
var child = null,
spawn = require('child_process').spawn;
function spawn_process(child_process) {
child_process = spawn('bash', ['lib/launch.sh']);
child_process.stdout.on('data', function(data) {
console.log('QEMU: ' + data);
});
child_process.stderr.on('data', function(data) {
console.log('ERR QEMU: ' + data);
});
child_process.on('exit', function(data) {
console.log('EXIT QEMU: ' + data);
spawn_process(child);
});
child = child_process;
}
spawn_process(child);
sub.on('connect', function() {
console.log('Connected to master.');
});
sub.on('disconnect', function() {
console.log('Disconnected from master.');
});
sub.on('message', function() {
var msg = arguments[1].toString();
process.stdout.write('> ' + msg);
child.stdin.write(msg);
child.stdin.write("\n");
});
process.stdin.resume();
process.stdin.on('data', function(data) {
child.stdin.write(data.toString());
});