{"action":"opened","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/3236","labels_url":"https://api.github.com/repos/nodejs/node/issues/3236/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/3236/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/3236/events","html_url":"https://github.com/nodejs/node/issues/3236","id":110223893,"number":3236,"title":"node 4.1.2 on OS X: child_process emits exit/close to wrong instance","user":{"login":"minesworld","id":10605116,"avatar_url":"https://avatars.githubusercontent.com/u/10605116?v=3","gravatar_id":"","url":"https://api.github.com/users/minesworld","html_url":"https://github.com/minesworld","followers_url":"https://api.github.com/users/minesworld/followers","following_url":"https://api.github.com/users/minesworld/following{/other_user}","gists_url":"https://api.github.com/users/minesworld/gists{/gist_id}","starred_url":"https://api.github.com/users/minesworld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minesworld/subscriptions","organizations_url":"https://api.github.com/users/minesworld/orgs","repos_url":"https://api.github.com/users/minesworld/repos","events_url":"https://api.github.com/users/minesworld/events{/privacy}","received_events_url":"https://api.github.com/users/minesworld/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-07T13:18:07Z","updated_at":"2015-10-07T13:18:07Z","closed_at":null,"body":"node --version => v4.1.2\r\nuname -a => Darwin xxx 15.0.0 Darwin Kernel Version 15.0.0: Wed Aug 26 16:57:32 PDT 2015; root:xnu-3247.1.106~1/RELEASE_X86_64 x86_64\r\n\r\nonly the last spawned child_process instance will get the emitted 'exit' and 'close' events, but this also for OTHER instances too...\r\n\r\n100% reproducable with this source:\r\n\r\n\r\n\r\nvar child_process = require('child_process');\r\n\r\nChildProcess = function(description, executable, arguments, callback) {\r\n  this.description = description;\r\n  this.exited = false;\r\n  \r\n  this.process = child_process.spawn(executable, arguments);\r\n  \r\n  self = this;\r\n  \r\n  this.process.on('exit', function(code, signal) {\r\n    \r\n    self.exited = true;\r\n    console.log(self.description + \" process.on:exit\", code, signal);\r\n    \r\n  }).on('close', function(code, signal) {\r\n\r\n    self.exited = true;\r\n    console.log(self.description + \" process.on:close\", code, signal);\r\n    \r\n    if (callback) callback(code, signal);\r\n    \r\n  }).on('error', function(err) {\r\n\r\n    console.log(self.description + \" process.on:error\", err);\r\n    \r\n  });\r\n}\r\n\r\nChildProcess.prototype.kill = function(signal) {\r\n  if (this.exited) return;\r\n  \r\n  console.log(this.description + \" .kill\", signal);\r\n  \r\n  this.process.kill(signal);\r\n}\r\n\r\n\r\np1 = new ChildProcess(\"p1\", \"/bin/sleep\", [ \"11\" ], function(code, signal) {\r\n  console.log(\"p1 <= \", code, signal);\r\n});\r\n\r\np2 = new ChildProcess(\"p2\", \"/bin/sleep\", [ \"12\" ], function(code, signal) {\r\n  console.log(\"p2 <= \", code, signal);\r\n});\r\n\r\nsetTimeout(function() {\r\n  p2.kill(\"SIGTERM\");\r\n  p1.kill(\"SIGTERM\");\r\n}, 1000);\r\n"}}