{"action":"created","comment":{"url":"https://api.github.com/repos/kripken/emscripten/pulls/comments/25111047","id":25111047,"diff_hunk":"@@ -95,13 +95,31 @@ mergeInto(LibraryManager.library, {\n         if (!tty.input.length) {\n           var result = null;\n           if (ENVIRONMENT_IS_NODE) {\n-            result = process['stdin']['read']();\n-            if (!result) {\n-              if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {\n-                return null;  // EOF\n+            // we will read data by chunks of BUFSIZE\n+            var BUFSIZE = 256;","path":"src/library_tty.js","position":9,"original_position":9,"commit_id":"9903c17e6e78f1655b9b1e3bbee8cf6492e6c105","original_commit_id":"9903c17e6e78f1655b9b1e3bbee8cf6492e6c105","user":{"login":"espadrine","id":100689,"avatar_url":"https://avatars.githubusercontent.com/u/100689?v=3","gravatar_id":"","url":"https://api.github.com/users/espadrine","html_url":"https://github.com/espadrine","followers_url":"https://api.github.com/users/espadrine/followers","following_url":"https://api.github.com/users/espadrine/following{/other_user}","gists_url":"https://api.github.com/users/espadrine/gists{/gist_id}","starred_url":"https://api.github.com/users/espadrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/espadrine/subscriptions","organizations_url":"https://api.github.com/users/espadrine/orgs","repos_url":"https://api.github.com/users/espadrine/repos","events_url":"https://api.github.com/users/espadrine/events{/privacy}","received_events_url":"https://api.github.com/users/espadrine/received_events","type":"User","site_admin":false},"body":"Chunking is the way node's readSync works, in a low-level BYOB way, reminiscent of C's stdio.\r\n\r\nThe requirement placed on this method is simply to produce a byte from stdin. The extra data is stored in tty.input. If more data needs to be read, this gets run again, appending more data. 256 is an arbitrary figure, a power of 2 for optimal allocation, and big enough to avoid having to perform blocking I/O too often for common use-cases.","created_at":"2015-02-20T23:05:04Z","updated_at":"2015-02-20T23:05:04Z","html_url":"https://github.com/kripken/emscripten/pull/3197#discussion_r25111047","pull_request_url":"https://api.github.com/repos/kripken/emscripten/pulls/3197","_links":{"self":{"href":"https://api.github.com/repos/kripken/emscripten/pulls/comments/25111047"},"html":{"href":"https://github.com/kripken/emscripten/pull/3197#discussion_r25111047"},"pull_request":{"href":"https://api.github.com/repos/kripken/emscripten/pulls/3197"}}},"pull_request":{"url":"https://api.github.com/repos/kripken/emscripten/pulls/3197","id":29406667,"html_url":"https://github.com/kripken/emscripten/pull/3197","diff_url":"https://github.com/kripken/emscripten/pull/3197.diff","patch_url":"https://github.com/kripken/emscripten/pull/3197.patch","issue_url":"https://api.github.com/repos/kripken/emscripten/issues/3197","number":3197,"state":"open","locked":false,"title":"support stdin in node","user":{"login":"espadrine","id":100689,"avatar_url":"https://avatars.githubusercontent.com/u/100689?v=3","gravatar_id":"","url":"https://api.github.com/users/espadrine","html_url":"https://github.com/espadrine","followers_url":"https://api.github.com/users/espadrine/followers","following_url":"https://api.github.com/users/espadrine/following{/other_user}","gists_url":"https://api.github.com/users/espadrine/gists{/gist_id}","starred_url":"https://api.github.com/users/espadrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/espadrine/subscriptions","organizations_url":"https://api.github.com/users/espadrine/orgs","repos_url":"https://api.github.com/users/espadrine/repos","events_url":"https://api.github.com/users/espadrine/events{/privacy}","received_events_url":"https://api.github.com/users/espadrine/received_events","type":"User","site_admin":false},"body":"The compiled JS programs failed to run on node when relying on stdin, because the code simply ignored any input stream and acted as if the empty string was entered, for simplicity (node doesn't… encourage… blocking stdin).\r\n\r\nI could not get emscripten to work on Windows. However, I did verify that all the pieces used in this PR worked on Windows (the way I handle stdin in node, and the way the test works (the python and shell bits)).\r\n\r\nOn Linux, `python tests/runner.py random100` gave an OK, and `python tests/runner.py other.test_stdin` worked, too.","created_at":"2015-02-16T23:04:42Z","updated_at":"2015-02-20T23:05:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d4e6c592ebb291ba878a676aeeb69704b4a011f4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kripken/emscripten/pulls/3197/commits","review_comments_url":"https://api.github.com/repos/kripken/emscripten/pulls/3197/comments","review_comment_url":"https://api.github.com/repos/kripken/emscripten/pulls/comments/{number}","comments_url":"https://api.github.com/repos/kripken/emscripten/issues/3197/comments","statuses_url":"https://api.github.com/repos/kripken/emscripten/statuses/9903c17e6e78f1655b9b1e3bbee8cf6492e6c105","head":{"label":"espadrine:incoming","ref":"incoming","sha":"9903c17e6e78f1655b9b1e3bbee8cf6492e6c105","user":{"login":"espadrine","id":100689,"avatar_url":"https://avatars.githubusercontent.com/u/100689?v=3","gravatar_id":"","url":"https://api.github.com/users/espadrine","html_url":"https://github.com/espadrine","followers_url":"https://api.github.com/users/espadrine/followers","following_url":"https://api.github.com/users/espadrine/following{/other_user}","gists_url":"https://api.github.com/users/espadrine/gists{/gist_id}","starred_url":"https://api.github.com/users/espadrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/espadrine/subscriptions","organizations_url":"https://api.github.com/users/espadrine/orgs","repos_url":"https://api.github.com/users/espadrine/repos","events_url":"https://api.github.com/users/espadrine/events{/privacy}","received_events_url":"https://api.github.com/users/espadrine/received_events","type":"User","site_admin":false},"repo":{"id":30556461,"name":"emscripten","full_name":"espadrine/emscripten","owner":{"login":"espadrine","id":100689,"avatar_url":"https://avatars.githubusercontent.com/u/100689?v=3","gravatar_id":"","url":"https://api.github.com/users/espadrine","html_url":"https://github.com/espadrine","followers_url":"https://api.github.com/users/espadrine/followers","following_url":"https://api.github.com/users/espadrine/following{/other_user}","gists_url":"https://api.github.com/users/espadrine/gists{/gist_id}","starred_url":"https://api.github.com/users/espadrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/espadrine/subscriptions","organizations_url":"https://api.github.com/users/espadrine/orgs","repos_url":"https://api.github.com/users/espadrine/repos","events_url":"https://api.github.com/users/espadrine/events{/privacy}","received_events_url":"https://api.github.com/users/espadrine/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/espadrine/emscripten","description":"Emscripten: An LLVM-to-JavaScript Compiler","fork":true,"url":"https://api.github.com/repos/espadrine/emscripten","forks_url":"https://api.github.com/repos/espadrine/emscripten/forks","keys_url":"https://api.github.com/repos/espadrine/emscripten/keys{/key_id}","collaborators_url":"https://api.github.com/repos/espadrine/emscripten/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/espadrine/emscripten/teams","hooks_url":"https://api.github.com/repos/espadrine/emscripten/hooks","issue_events_url":"https://api.github.com/repos/espadrine/emscripten/issues/events{/number}","events_url":"https://api.github.com/repos/espadrine/emscripten/events","assignees_url":"https://api.github.com/repos/espadrine/emscripten/assignees{/user}","branches_url":"https://api.github.com/repos/espadrine/emscripten/branches{/branch}","tags_url":"https://api.github.com/repos/espadrine/emscripten/tags","blobs_url":"https://api.github.com/repos/espadrine/emscripten/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/espadrine/emscripten/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/espadrine/emscripten/git/refs{/sha}","trees_url":"https://api.github.com/repos/espadrine/emscripten/git/trees{/sha}","statuses_url":"https://api.github.com/repos/espadrine/emscripten/statuses/{sha}","languages_url":"https://api.github.com/repos/espadrine/emscripten/languages","stargazers_url":"https://api.github.com/repos/espadrine/emscripten/stargazers","contributors_url":"https://api.github.com/repos/espadrine/emscripten/contributors","subscribers_url":"https://api.github.com/repos/espadrine/emscripten/subscribers","subscription_url":"https://api.github.com/repos/espadrine/emscripten/subscription","commits_url":"https://api.github.com/repos/espadrine/emscripten/commits{/sha}","git_commits_url":"https://api.github.com/repos/espadrine/emscripten/git/commits{/sha}","comments_url":"https://api.github.com/repos/espadrine/emscripten/comments{/number}","issue_comment_url":"https://api.github.com/repos/espadrine/emscripten/issues/comments/{number}","contents_url":"https://api.github.com/repos/espadrine/emscripten/contents/{+path}","compare_url":"https://api.github.com/repos/espadrine/emscripten/compare/{base}...{head}","merges_url":"https://api.github.com/repos/espadrine/emscripten/merges","archive_url":"https://api.github.com/repos/espadrine/emscripten/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/espadrine/emscripten/downloads","issues_url":"https://api.github.com/repos/espadrine/emscripten/issues{/number}","pulls_url":"https://api.github.com/repos/espadrine/emscripten/pulls{/number}","milestones_url":"https://api.github.com/repos/espadrine/emscripten/milestones{/number}","notifications_url":"https://api.github.com/repos/espadrine/emscripten/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/espadrine/emscripten/labels{/name}","releases_url":"https://api.github.com/repos/espadrine/emscripten/releases{/id}","created_at":"2015-02-09T20:21:10Z","updated_at":"2015-02-09T20:21:29Z","pushed_at":"2015-02-18T21:08:18Z","git_url":"git://github.com/espadrine/emscripten.git","ssh_url":"git@github.com:espadrine/emscripten.git","clone_url":"https://github.com/espadrine/emscripten.git","svn_url":"https://github.com/espadrine/emscripten","homepage":"","size":115348,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"kripken:incoming","ref":"incoming","sha":"41160fa339331f844590d2c739c3ac901cb06aed","user":{"login":"kripken","id":173661,"avatar_url":"https://avatars.githubusercontent.com/u/173661?v=3","gravatar_id":"","url":"https://api.github.com/users/kripken","html_url":"https://github.com/kripken","followers_url":"https://api.github.com/users/kripken/followers","following_url":"https://api.github.com/users/kripken/following{/other_user}","gists_url":"https://api.github.com/users/kripken/gists{/gist_id}","starred_url":"https://api.github.com/users/kripken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kripken/subscriptions","organizations_url":"https://api.github.com/users/kripken/orgs","repos_url":"https://api.github.com/users/kripken/repos","events_url":"https://api.github.com/users/kripken/events{/privacy}","received_events_url":"https://api.github.com/users/kripken/received_events","type":"User","site_admin":false},"repo":{"id":1357796,"name":"emscripten","full_name":"kripken/emscripten","owner":{"login":"kripken","id":173661,"avatar_url":"https://avatars.githubusercontent.com/u/173661?v=3","gravatar_id":"","url":"https://api.github.com/users/kripken","html_url":"https://github.com/kripken","followers_url":"https://api.github.com/users/kripken/followers","following_url":"https://api.github.com/users/kripken/following{/other_user}","gists_url":"https://api.github.com/users/kripken/gists{/gist_id}","starred_url":"https://api.github.com/users/kripken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kripken/subscriptions","organizations_url":"https://api.github.com/users/kripken/orgs","repos_url":"https://api.github.com/users/kripken/repos","events_url":"https://api.github.com/users/kripken/events{/privacy}","received_events_url":"https://api.github.com/users/kripken/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kripken/emscripten","description":"Emscripten: An LLVM-to-JavaScript Compiler","fork":false,"url":"https://api.github.com/repos/kripken/emscripten","forks_url":"https://api.github.com/repos/kripken/emscripten/forks","keys_url":"https://api.github.com/repos/kripken/emscripten/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kripken/emscripten/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kripken/emscripten/teams","hooks_url":"https://api.github.com/repos/kripken/emscripten/hooks","issue_events_url":"https://api.github.com/repos/kripken/emscripten/issues/events{/number}","events_url":"https://api.github.com/repos/kripken/emscripten/events","assignees_url":"https://api.github.com/repos/kripken/emscripten/assignees{/user}","branches_url":"https://api.github.com/repos/kripken/emscripten/branches{/branch}","tags_url":"https://api.github.com/repos/kripken/emscripten/tags","blobs_url":"https://api.github.com/repos/kripken/emscripten/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kripken/emscripten/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kripken/emscripten/git/refs{/sha}","trees_url":"https://api.github.com/repos/kripken/emscripten/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kripken/emscripten/statuses/{sha}","languages_url":"https://api.github.com/repos/kripken/emscripten/languages","stargazers_url":"https://api.github.com/repos/kripken/emscripten/stargazers","contributors_url":"https://api.github.com/repos/kripken/emscripten/contributors","subscribers_url":"https://api.github.com/repos/kripken/emscripten/subscribers","subscription_url":"https://api.github.com/repos/kripken/emscripten/subscription","commits_url":"https://api.github.com/repos/kripken/emscripten/commits{/sha}","git_commits_url":"https://api.github.com/repos/kripken/emscripten/git/commits{/sha}","comments_url":"https://api.github.com/repos/kripken/emscripten/comments{/number}","issue_comment_url":"https://api.github.com/repos/kripken/emscripten/issues/comments/{number}","contents_url":"https://api.github.com/repos/kripken/emscripten/contents/{+path}","compare_url":"https://api.github.com/repos/kripken/emscripten/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kripken/emscripten/merges","archive_url":"https://api.github.com/repos/kripken/emscripten/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kripken/emscripten/downloads","issues_url":"https://api.github.com/repos/kripken/emscripten/issues{/number}","pulls_url":"https://api.github.com/repos/kripken/emscripten/pulls{/number}","milestones_url":"https://api.github.com/repos/kripken/emscripten/milestones{/number}","notifications_url":"https://api.github.com/repos/kripken/emscripten/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kripken/emscripten/labels{/name}","releases_url":"https://api.github.com/repos/kripken/emscripten/releases{/id}","created_at":"2011-02-12T05:23:30Z","updated_at":"2015-02-20T22:06:23Z","pushed_at":"2015-02-20T22:58:07Z","git_url":"git://github.com/kripken/emscripten.git","ssh_url":"git@github.com:kripken/emscripten.git","clone_url":"https://github.com/kripken/emscripten.git","svn_url":"https://github.com/kripken/emscripten","homepage":"","size":196275,"stargazers_count":7866,"watchers_count":7866,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":874,"mirror_url":null,"open_issues_count":545,"forks":874,"open_issues":545,"watchers":7866,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kripken/emscripten/pulls/3197"},"html":{"href":"https://github.com/kripken/emscripten/pull/3197"},"issue":{"href":"https://api.github.com/repos/kripken/emscripten/issues/3197"},"comments":{"href":"https://api.github.com/repos/kripken/emscripten/issues/3197/comments"},"review_comments":{"href":"https://api.github.com/repos/kripken/emscripten/pulls/3197/comments"},"review_comment":{"href":"https://api.github.com/repos/kripken/emscripten/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/kripken/emscripten/pulls/3197/commits"},"statuses":{"href":"https://api.github.com/repos/kripken/emscripten/statuses/9903c17e6e78f1655b9b1e3bbee8cf6492e6c105"}}}}