From 680964fca5d82384243a6f04a99accb95d20d2fd Mon Sep 17 00:00:00 2001 From: Niko Fink Date: Wed, 12 Oct 2016 10:34:56 -0400 Subject: [PATCH] don't fail silently Redirect subprocess stderr to parent's stderr and print error events when the child process could not be spawned or killed. --- main.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 9293c99..ea39a72 100644 --- a/main.js +++ b/main.js @@ -12,7 +12,7 @@ var mainProcessShutdown = false; var initChildProcess = function() { - child = spawn("node", [__dirname + "/" + "rc522_output.js"]); + child = spawn("node", [__dirname + "/" + "rc522_output.js"], { stdio: ['pipe', 'pipe', process.stderr] }); var linereader = readline.createInterface(child.stdout, child.stdin); linereader.on('line', function (rfidTagSerialNumber) { @@ -28,6 +28,10 @@ var initChildProcess = function() initChildProcess(); } }); + + child.on('error', function(err) { + console.log("Error with RC522 subprocess", err); + }); }; // SIGTERM AND SIGINT will trigger the exit event.