{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/3669","labels_url":"https://api.github.com/repos/nodejs/node/issues/3669/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/3669/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/3669/events","html_url":"https://github.com/nodejs/node/issues/3669","id":115186156,"number":3669,"title":"process.stdout/.stderr might loose data when calling process.exit()","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":[{"url":"https://api.github.com/repos/nodejs/node/labels/duplicate","name":"duplicate","color":"ededed"},{"url":"https://api.github.com/repos/nodejs/node/labels/process","name":"process","color":"00aaff"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-05T01:03:45Z","updated_at":"2015-11-05T01:08:49Z","closed_at":"2015-11-05T01:08:49Z","body":"this won't work reliable (but it should according to the docs):\r\n\r\n```javascript\r\n  var empty = new Buffer(0)\r\n  process.stdout.write(empty, function() { \r\n    process.stderr.write(empty, function() { \r\n       process.exit(code);\r\n    });\r\n  });\r\n```\r\n\r\nNot all data is flushed when node.js ends and thus another process using its output will not get all written data.\r\n\r\nIt also doesn't help to use something like\r\n\r\n```javascript\r\nstream.pipe(process.stdout);\r\nstream.push(null);\r\n```\r\n\r\nThat .end() throws and an finish is never emitted makes using process.stdout/.stderr something like lottery.\r\n\r\nAlso trying to workaround via \r\n\r\n```javascript\r\nfs.createWritableStream(null, {fd:1});\r\n```\r\n\r\nleads to another bunch of problems like EAGAIN errors.\r\n\r\nI would suggest to implement .end() and finish events so that both process.stdout and .stderr behave like any other stream."},"comment":{"url":"https://api.github.com/repos/nodejs/node/issues/comments/153920837","html_url":"https://github.com/nodejs/node/issues/3669#issuecomment-153920837","issue_url":"https://api.github.com/repos/nodejs/node/issues/3669","id":153920837,"user":{"login":"Fishrock123","id":1093990,"avatar_url":"https://avatars.githubusercontent.com/u/1093990?v=3","gravatar_id":"","url":"https://api.github.com/users/Fishrock123","html_url":"https://github.com/Fishrock123","followers_url":"https://api.github.com/users/Fishrock123/followers","following_url":"https://api.github.com/users/Fishrock123/following{/other_user}","gists_url":"https://api.github.com/users/Fishrock123/gists{/gist_id}","starred_url":"https://api.github.com/users/Fishrock123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fishrock123/subscriptions","organizations_url":"https://api.github.com/users/Fishrock123/orgs","repos_url":"https://api.github.com/users/Fishrock123/repos","events_url":"https://api.github.com/users/Fishrock123/events{/privacy}","received_events_url":"https://api.github.com/users/Fishrock123/received_events","type":"User","site_admin":false},"created_at":"2015-11-05T01:08:49Z","updated_at":"2015-11-05T01:08:49Z","body":"Please see https://github.com/nodejs/node/issues/2972#issuecomment-146078649\r\n\r\n(Oh dear, this again.)"}}