From e4da9fa7e132e193a33a0158af1066cad1154f63 Mon Sep 17 00:00:00 2001 From: Matt Gollob Date: Fri, 3 May 2013 16:28:50 -0400 Subject: [PATCH] Fix hang after SIGINT in debug mode Sending SIGINT (^c) to the process when in debug mode causes the process to (at least appear to) hang, because the serial port is still open. Instead of deleting our reference to the serialport, call its close method, and then call process.exit in the handler for the close event. --- lib/board.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/board.js b/lib/board.js index a1acf89..1da3074 100644 --- a/lib/board.js +++ b/lib/board.js @@ -42,10 +42,10 @@ var Board = function (options) { process.on('SIGINT', function(){ self.log('info', 'sending debug mode toggle off to board'); self.write('99' + self.normalizePin(0) + self.normalizeVal(0)); - delete self.serial; - setTimeout(function(){ - process.exit(); - }, 100); + self.serial.once('close', function() { + setTimeout(process.exit, 100); + }); + self.serial.close(); }); }