{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/3389","labels_url":"https://api.github.com/repos/nodejs/node/issues/3389/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/3389/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/3389/events","html_url":"https://github.com/nodejs/node/issues/3389","id":111717719,"number":3389,"title":"child_process.execFile returns strings where doc says it should return a Buffer","user":{"login":"nixar","id":157654,"avatar_url":"https://avatars.githubusercontent.com/u/157654?v=3","gravatar_id":"","url":"https://api.github.com/users/nixar","html_url":"https://github.com/nixar","followers_url":"https://api.github.com/users/nixar/followers","following_url":"https://api.github.com/users/nixar/following{/other_user}","gists_url":"https://api.github.com/users/nixar/gists{/gist_id}","starred_url":"https://api.github.com/users/nixar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nixar/subscriptions","organizations_url":"https://api.github.com/users/nixar/orgs","repos_url":"https://api.github.com/users/nixar/repos","events_url":"https://api.github.com/users/nixar/events{/privacy}","received_events_url":"https://api.github.com/users/nixar/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nodejs/node/labels/child_process","name":"child_process","color":"f7c6c7"},{"url":"https://api.github.com/repos/nodejs/node/labels/doc","name":"doc","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-10-15T22:04:22Z","updated_at":"2015-10-16T03:46:39Z","closed_at":null,"body":"[Doc says](https://nodejs.org/api/child_process.html#child_process_child_process_execfile_file_args_options_callback): \r\n\r\n> callback Function called with the output when process terminates\r\n> - error Error\r\n> - stdout Buffer\r\n> - stderr Buffer\r\n\r\n[This was known back in 2013 already](http://stackoverflow.com/questions/18925426/child-process-the-stdout-parameter)\r\n\r\nThis points out the options parameter's encoding field can force a buffer response. However the default value is supposed to be 'utf8' according to the doc, which strongly implies that it means _character encoding_, not the type of the return value. The name of this option is terribly misleading. \r\n\r\nDemo code:\r\n\r\n```\r\n\"use strict\";\r\nvar child_process = require('child_process');\r\nconsole.log('node version=%s',process.version);\r\n\r\nfor (let options of [{}, {encoding:'buffer'}]) {\r\n  child_process.execFile(\r\n    'uname', ['-o'], options,\r\n    (error, stdout, stderr) => {\r\n      console.log(\r\n        'options is %s → stdout is a %s', \r\n        JSON.stringify(options), \r\n        typeof stdout\r\n      )\r\n    }\r\n  );\r\n}\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nnode version=v4.2.1\r\noptions is {\"encoding\":\"buffer\"} → stdout is a object\r\noptions is {} → stdout is a string\r\n```\r\n\r\nThe behavior or the documentation need to be changed. If the current behavior is kept, the semantic of 'encoding' should be clarified, and the name of the property should be changed (to 'return_type' for example)."},"comment":{"url":"https://api.github.com/repos/nodejs/node/issues/comments/148592238","html_url":"https://github.com/nodejs/node/issues/3389#issuecomment-148592238","issue_url":"https://api.github.com/repos/nodejs/node/issues/3389","id":148592238,"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-10-16T03:46:39Z","updated_at":"2015-10-16T03:46:39Z","body":"It should probably say like `Buffer | String` (in which ever format we use throughout the docs)."}}