summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/internal/child_process.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js
index abd4b16d12..68dd1145d3 100644
--- a/lib/internal/child_process.js
+++ b/lib/internal/child_process.js
@@ -645,16 +645,15 @@ function setupChannel(target, channel) {
obj.postSend(handle, options, target);
}
- req.oncomplete = function() {
- if (this.async === true)
+ if (req.async) {
+ req.oncomplete = function() {
control.unref();
- if (typeof callback === 'function')
- callback(null);
- };
- if (req.async === true) {
+ if (typeof callback === 'function')
+ callback(null);
+ };
control.ref();
- } else {
- process.nextTick(function() { req.oncomplete(); });
+ } else if (typeof callback === 'function') {
+ process.nextTick(callback, null);
}
} else {
// Cleanup handle on error