Skip to content

Instantly share code, notes, and snippets.

@nicklozon
Created April 22, 2016 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicklozon/babeda60b53e799b4b43677ab710e74c to your computer and use it in GitHub Desktop.
Save nicklozon/babeda60b53e799b4b43677ab710e74c to your computer and use it in GitHub Desktop.
'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