From 63ee4d1e7d73d2e6713c9f9a1ba80bb3620420b8 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Fri, 13 Mar 2015 10:10:21 +0000 Subject: [PATCH] use close event instead of exit to capture stdout/stderr correctly --- services/filestore/app/coffee/SafeExec.coffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/filestore/app/coffee/SafeExec.coffee b/services/filestore/app/coffee/SafeExec.coffee index 65da163538..0244f14783 100644 --- a/services/filestore/app/coffee/SafeExec.coffee +++ b/services/filestore/app/coffee/SafeExec.coffee @@ -27,8 +27,9 @@ module.exports = (command, options, callback = (err, stdout, stderr) ->) -> logger.log process: child.pid, kill_error: error, "error killing process" , options.timeout - child.on 'exit', (code, signal) -> - cleanup signal + child.on 'close', (code, signal) -> + err = if code then new Error("exit status #{code}") else signal + cleanup err child.on 'error', (err) -> cleanup err