Created
April 22, 2016 11:49
-
-
Save nicklozon/babeda60b53e799b4b43677ab710e74c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var spawn = require('child_process').spawn; | |
var cpu = require('./available-configs/cpu.json'); | |
// Use Gnu stdbuf to avoid buffering from commands | |
var child = spawn('stdbuf', ['-oL', 'bash', '-c', cpu.command]); | |
child.stdout.on('data', function(data) { | |
process.stdout.write(data); | |
}); | |
child.stderr.on('data', function(data) { | |
process.stderr.write(data); | |
}); | |
child.on('close', function(code) { | |
if(code !== 0) { | |
console.log(`exited with error code ${code}`); | |
} | |
}); | |
child.on('error', function(err) { | |
console.log(`Failed to start process.`); | |
console.log(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment