diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc index 93e51af38f65ae..8ef78a796db2ec 100644 --- a/src/spawn_sync.cc +++ b/src/spawn_sync.cc @@ -650,12 +650,17 @@ Local SyncProcessRunner::BuildResultObject() { Integer::New(env()->isolate(), GetError())); } - if (exit_status_ >= 0) - js_result->Set(env()->status_string(), - Number::New(env()->isolate(), static_cast(exit_status_))); - else + if (exit_status_ >= 0) { + if (term_signal_ > 0) { + js_result->Set(env()->status_string(), Null(env()->isolate())); + } else { + js_result->Set(env()->status_string(), + Number::New(env()->isolate(), static_cast(exit_status_))); + } + } else { // If exit_status_ < 0 the process was never started because of some error. js_result->Set(env()->status_string(), Null(env()->isolate())); + } if (term_signal_ > 0) js_result->Set(env()->signal_string(), diff --git a/test/parallel/test-child-process-spawnsync-kill-signal.js b/test/parallel/test-child-process-spawnsync-kill-signal.js index 8a3c362216eac5..b0d47e0aa68f5c 100644 --- a/test/parallel/test-child-process-spawnsync-kill-signal.js +++ b/test/parallel/test-child-process-spawnsync-kill-signal.js @@ -1,12 +1,11 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const cp = require('child_process'); if (process.argv[2] === 'child') { setInterval(() => {}, 1000); } else { - const exitCode = common.isWindows ? 1 : 0; const { SIGKILL } = process.binding('constants').os.signals; function spawn(killSignal) { @@ -14,7 +13,7 @@ if (process.argv[2] === 'child') { [__filename, 'child'], {killSignal, timeout: 100}); - assert.strictEqual(child.status, exitCode); + assert.strictEqual(child.status, null); assert.strictEqual(child.error.code, 'ETIMEDOUT'); return child; }