From 5fc2d976091f3ea8f76f37939031e57b1953b19c Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 25 Feb 2017 22:39:40 -0500 Subject: [PATCH] fix so child process doesn't hang some cmds --- lib/contracts/solcP.js | 4 ++++ lib/contracts/solcW.js | 5 +++-- lib/index.js | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/contracts/solcP.js b/lib/contracts/solcP.js index 257579f6..2332091f 100644 --- a/lib/contracts/solcP.js +++ b/lib/contracts/solcP.js @@ -12,3 +12,7 @@ process.on('message', function(msg) { } }); +process.on('exit', function() { + process.exit(0); +}); + diff --git a/lib/contracts/solcW.js b/lib/contracts/solcW.js index 8c9b0523..a3c9c33a 100644 --- a/lib/contracts/solcW.js +++ b/lib/contracts/solcW.js @@ -1,4 +1,4 @@ -var solcProcess = require('child_process').fork(__dirname + '/solcP.js'); +var solcProcess; var compilerLoaded = false; var SolcW = function() { @@ -6,6 +6,7 @@ var SolcW = function() { SolcW.prototype.load_compiler = function(done) { if (compilerLoaded) { done(); } + solcProcess = require('child_process').fork(__dirname + '/solcP.js'); solcProcess.once('message', function(msg) { if (msg.result !== 'loadedCompiler') { return; @@ -18,7 +19,7 @@ SolcW.prototype.load_compiler = function(done) { SolcW.prototype.isCompilerLoaded = function() { return (compilerLoaded === true); -} +}; SolcW.prototype.compile = function(obj, optimize, done) { solcProcess.once('message', function(msg) { diff --git a/lib/index.js b/lib/index.js index aa64a034..1123922d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -238,13 +238,14 @@ var Embark = { pipeline.build(abi); callback(); } - ], function(err, result) { if (err) { self.logger.error(err.message); } else { - self.logger.trace("finished".underline); + self.logger.info("finished building".underline); } + // needed due to child processes + process.exit(); }); },