#111 Fix a crash when attempting to use `bunyan -p` on a platform without dtrace.

Also fix exit status if the spawned dtrace exits non-zero.
master
Trent Mick 2013-11-25 23:46:30 -08:00
parent f4f8f3e148
commit 6208e87eca
2 changed files with 14 additions and 1 deletions

View File

@ -8,6 +8,9 @@ Known issues:
## bunyan 0.22.1 (not yet released)
- #111 Fix a crash when attempting to use `bunyan -p` on a platform without
dtrace.
- #101 Fix a crash in `bunyan` rendering a record with unexpected "res.headers".

View File

@ -1129,6 +1129,15 @@ function processPids(opts, stylize, callback) {
// Share the stderr handle to have error output come
// straight through. Only supported in v0.8+.
{stdio: ['pipe', 'pipe', process.stderr]});
dtrace.on('error', function (e) {
if (e.syscall === 'spawn' && e.errno === 'ENOENT') {
console.error('bunyan: error: could not spawn "dtrace" ' +
'("bunyan -p" is only supported on platforms with dtrace)');
} else {
console.error('bunyan: error: unexpected dtrace error: %s', e);
}
callback(1);
})
child = dtrace; // intentionally global
function finish(code) {
@ -1136,7 +1145,7 @@ function processPids(opts, stylize, callback) {
handleLogLine(null, leftover, opts, stylize);
leftover = '';
}
callback(returnCode);
callback(code);
}
dtrace.stdout.setEncoding('utf8');
@ -1350,6 +1359,7 @@ process.on('uncaughtException', function (err) {
e('* https://github.com/trentm/node-bunyan/issues/new?title=%s', title);
e('*');
e('* * *');
e('* platform:', process.platform);
e('* node version:', process.version);
e('* bunyan version:', getVersion());
e('* argv: %j', process.argv);