{"action":"created","comment":{"url":"https://api.github.com/repos/dshil/playground/pulls/comments/106890222","pull_request_review_id":27831989,"id":106890222,"diff_hunk":"@@ -238,3 +247,138 @@ static int read_tail_blocks(FILE *f, char *filename)\n \n \treturn read_and_print_bytes(f, filename, size);\n }\n+\n+static void usage(char *prog_name)\n+{\n+\tfprintf(stderr,\n+\t\t\t\"Usage: %s [-q] [-f file] [-b blocks | -c bytes | -n lines] [file ...]\\n\",\n+\t\t\tprog_name);\n+}\n+\n+static int listen_file_changes(char *filename)\n+{\n+\tssize_t ifd = 0;\n+\tssize_t wfd = 0;\n+\n+\t/* Create the file descriptor for accessing the inotify API */\n+\tif ((ifd = inotify_init1(IN_NONBLOCK)) == -1) {\n+\t\tperror(\"inotify_init1\");\n+\t\tgoto error;\n+\t}\n+\n+\t/* Add a new watch for the filename */\n+\tif ((wfd = inotify_add_watch(ifd, filename, IN_MODIFY)) == -1) {\n+\t\tperror(\"inotify_add_watch\");\n+\t\tgoto error;\n+\t}\n+\n+\t/* Prepare for polling */\n+\tnfds_t nfds = 2; /* number of file descriptors for polling */\n+\tstruct pollfd fds[2];\n+\n+\t/* Console input */\n+\tfds[0].fd = STDIN_FILENO;\n+\tfds[1].events = POLLIN;\n+\n+\t/* Inotify input */\n+\tfds[1].fd = ifd;\n+\tfds[1].events = POLLIN;\n+\n+\tint poll_num = 0;\n+\t/* Wait for events and/or terminal input */\n+\twhile(1) {\n+\t\tif ((poll_num = poll(fds, nfds, -1)) == -1) {\n+\t\t\tperror(\"poll\");\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tif (poll_num > 0) {\n+\t\t\tif (fds[0].revents & POLLIN) {\n+\t\t\t\t/* Console input is available */\n+\t\t\t}\n+\n+\t\t\tif (fds[1].revents & POLLIN) {\n+\t\t\t\tif (handle_inotify_events(ifd, wfd, filename) == -1)","path":"c/coreutils/tail.c","position":156,"original_position":156,"commit_id":"b1fa9ef7280639e4a5ed1919ac4697ee57d976a6","original_commit_id":"b1fa9ef7280639e4a5ed1919ac4697ee57d976a6","user":{"login":"dshil","id":8618625,"avatar_url":"https://avatars1.githubusercontent.com/u/8618625?v=3","gravatar_id":"","url":"https://api.github.com/users/dshil","html_url":"https://github.com/dshil","followers_url":"https://api.github.com/users/dshil/followers","following_url":"https://api.github.com/users/dshil/following{/other_user}","gists_url":"https://api.github.com/users/dshil/gists{/gist_id}","starred_url":"https://api.github.com/users/dshil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dshil/subscriptions","organizations_url":"https://api.github.com/users/dshil/orgs","repos_url":"https://api.github.com/users/dshil/repos","events_url":"https://api.github.com/users/dshil/events{/privacy}","received_events_url":"https://api.github.com/users/dshil/received_events","type":"User","site_admin":false},"body":"Don't forget to check if 0 was return","created_at":"2017-03-20T12:41:25Z","updated_at":"2017-03-20T12:41:25Z","html_url":"https://github.com/dshil/playground/pull/25#discussion_r106890222","pull_request_url":"https://api.github.com/repos/dshil/playground/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/dshil/playground/pulls/comments/106890222"},"html":{"href":"https://github.com/dshil/playground/pull/25#discussion_r106890222"},"pull_request":{"href":"https://api.github.com/repos/dshil/playground/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/dshil/playground/pulls/25","id":111412811,"html_url":"https://github.com/dshil/playground/pull/25","diff_url":"https://github.com/dshil/playground/pull/25.diff","patch_url":"https://github.com/dshil/playground/pull/25.patch","issue_url":"https://api.github.com/repos/dshil/playground/issues/25","number":25,"state":"open","locked":false,"title":"coreutils-tail: fix jump into scope of identifier with variably modified","user":{"login":"dshil","id":8618625,"avatar_url":"https://avatars1.githubusercontent.com/u/8618625?v=3","gravatar_id":"","url":"https://api.github.com/users/dshil","html_url":"https://github.com/dshil","followers_url":"https://api.github.com/users/dshil/followers","following_url":"https://api.github.com/users/dshil/following{/other_user}","gists_url":"https://api.github.com/users/dshil/gists{/gist_id}","starred_url":"https://api.github.com/users/dshil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dshil/subscriptions","organizations_url":"https://api.github.com/users/dshil/orgs","repos_url":"https://api.github.com/users/dshil/repos","events_url":"https://api.github.com/users/dshil/events{/privacy}","received_events_url":"https://api.github.com/users/dshil/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-03-18T14:52:12Z","updated_at":"2017-03-20T12:41:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15dd67976b3d9ab0fa6787af2692a6a17c07c0c0","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dshil/playground/pulls/25/commits","review_comments_url":"https://api.github.com/repos/dshil/playground/pulls/25/comments","review_comment_url":"https://api.github.com/repos/dshil/playground/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dshil/playground/issues/25/comments","statuses_url":"https://api.github.com/repos/dshil/playground/statuses/b1fa9ef7280639e4a5ed1919ac4697ee57d976a6","head":{"label":"dshil:improve-tail","ref":"improve-tail","sha":"b1fa9ef7280639e4a5ed1919ac4697ee57d976a6","user":{"login":"dshil","id":8618625,"avatar_url":"https://avatars1.githubusercontent.com/u/8618625?v=3","gravatar_id":"","url":"https://api.github.com/users/dshil","html_url":"https://github.com/dshil","followers_url":"https://api.github.com/users/dshil/followers","following_url":"https://api.github.com/users/dshil/following{/other_user}","gists_url":"https://api.github.com/users/dshil/gists{/gist_id}","starred_url":"https://api.github.com/users/dshil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dshil/subscriptions","organizations_url":"https://api.github.com/users/dshil/orgs","repos_url":"https://api.github.com/users/dshil/repos","events_url":"https://api.github.com/users/dshil/events{/privacy}","received_events_url":"https://api.github.com/users/dshil/received_events","type":"User","site_admin":false},"repo":{"id":67857303,"name":"playground","full_name":"dshil/playground","owner":{"login":"dshil","id":8618625,"avatar_url":"https://avatars1.githubusercontent.com/u/8618625?v=3","gravatar_id":"","url":"https://api.github.com/users/dshil","html_url":"https://github.com/dshil","followers_url":"https://api.github.com/users/dshil/followers","following_url":"https://api.github.com/users/dshil/following{/other_user}","gists_url":"https://api.github.com/users/dshil/gists{/gist_id}","starred_url":"https://api.github.com/users/dshil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dshil/subscriptions","organizations_url":"https://api.github.com/users/dshil/orgs","repos_url":"https://api.github.com/users/dshil/repos","events_url":"https://api.github.com/users/dshil/events{/privacy}","received_events_url":"https://api.github.com/users/dshil/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dshil/playground","description":"pet projects","fork":false,"url":"https://api.github.com/repos/dshil/playground","forks_url":"https://api.github.com/repos/dshil/playground/forks","keys_url":"https://api.github.com/repos/dshil/playground/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dshil/playground/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dshil/playground/teams","hooks_url":"https://api.github.com/repos/dshil/playground/hooks","issue_events_url":"https://api.github.com/repos/dshil/playground/issues/events{/number}","events_url":"https://api.github.com/repos/dshil/playground/events","assignees_url":"https://api.github.com/repos/dshil/playground/assignees{/user}","branches_url":"https://api.github.com/repos/dshil/playground/branches{/branch}","tags_url":"https://api.github.com/repos/dshil/playground/tags","blobs_url":"https://api.github.com/repos/dshil/playground/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dshil/playground/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dshil/playground/git/refs{/sha}","trees_url":"https://api.github.com/repos/dshil/playground/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dshil/playground/statuses/{sha}","languages_url":"https://api.github.com/repos/dshil/playground/languages","stargazers_url":"https://api.github.com/repos/dshil/playground/stargazers","contributors_url":"https://api.github.com/repos/dshil/playground/contributors","subscribers_url":"https://api.github.com/repos/dshil/playground/subscribers","subscription_url":"https://api.github.com/repos/dshil/playground/subscription","commits_url":"https://api.github.com/repos/dshil/playground/commits{/sha}","git_commits_url":"https://api.github.com/repos/dshil/playground/git/commits{/sha}","comments_url":"https://api.github.com/repos/dshil/playground/comments{/number}","issue_comment_url":"https://api.github.com/repos/dshil/playground/issues/comments{/number}","contents_url":"https://api.github.com/repos/dshil/playground/contents/{+path}","compare_url":"https://api.github.com/repos/dshil/playground/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dshil/playground/merges","archive_url":"https://api.github.com/repos/dshil/playground/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dshil/playground/downloads","issues_url":"https://api.github.com/repos/dshil/playground/issues{/number}","pulls_url":"https://api.github.com/repos/dshil/playground/pulls{/number}","milestones_url":"https://api.github.com/repos/dshil/playground/milestones{/number}","notifications_url":"https://api.github.com/repos/dshil/playground/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dshil/playground/labels{/name}","releases_url":"https://api.github.com/repos/dshil/playground/releases{/id}","deployments_url":"https://api.github.com/repos/dshil/playground/deployments","created_at":"2016-09-10T07:23:15Z","updated_at":"2017-03-13T03:19:28Z","pushed_at":"2017-03-20T06:02:36Z","git_url":"git://github.com/dshil/playground.git","ssh_url":"git@github.com:dshil/playground.git","clone_url":"https://github.com/dshil/playground.git","svn_url":"https://github.com/dshil/playground","homepage":"","size":67,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":0,"default_branch":"master"}},"base":{"label":"dshil:master","ref":"master","sha":"3954cf038e2a096732e705eaf167d17bdacfd555","user":{"login":"dshil","id":8618625,"avatar_url":"https://avatars1.githubusercontent.com/u/8618625?v=3","gravatar_id":"","url":"https://api.github.com/users/dshil","html_url":"https://github.com/dshil","followers_url":"https://api.github.com/users/dshil/followers","following_url":"https://api.github.com/users/dshil/following{/other_user}","gists_url":"https://api.github.com/users/dshil/gists{/gist_id}","starred_url":"https://api.github.com/users/dshil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dshil/subscriptions","organizations_url":"https://api.github.com/users/dshil/orgs","repos_url":"https://api.github.com/users/dshil/repos","events_url":"https://api.github.com/users/dshil/events{/privacy}","received_events_url":"https://api.github.com/users/dshil/received_events","type":"User","site_admin":false},"repo":{"id":67857303,"name":"playground","full_name":"dshil/playground","owner":{"login":"dshil","id":8618625,"avatar_url":"https://avatars1.githubusercontent.com/u/8618625?v=3","gravatar_id":"","url":"https://api.github.com/users/dshil","html_url":"https://github.com/dshil","followers_url":"https://api.github.com/users/dshil/followers","following_url":"https://api.github.com/users/dshil/following{/other_user}","gists_url":"https://api.github.com/users/dshil/gists{/gist_id}","starred_url":"https://api.github.com/users/dshil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dshil/subscriptions","organizations_url":"https://api.github.com/users/dshil/orgs","repos_url":"https://api.github.com/users/dshil/repos","events_url":"https://api.github.com/users/dshil/events{/privacy}","received_events_url":"https://api.github.com/users/dshil/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dshil/playground","description":"pet projects","fork":false,"url":"https://api.github.com/repos/dshil/playground","forks_url":"https://api.github.com/repos/dshil/playground/forks","keys_url":"https://api.github.com/repos/dshil/playground/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dshil/playground/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dshil/playground/teams","hooks_url":"https://api.github.com/repos/dshil/playground/hooks","issue_events_url":"https://api.github.com/repos/dshil/playground/issues/events{/number}","events_url":"https://api.github.com/repos/dshil/playground/events","assignees_url":"https://api.github.com/repos/dshil/playground/assignees{/user}","branches_url":"https://api.github.com/repos/dshil/playground/branches{/branch}","tags_url":"https://api.github.com/repos/dshil/playground/tags","blobs_url":"https://api.github.com/repos/dshil/playground/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dshil/playground/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dshil/playground/git/refs{/sha}","trees_url":"https://api.github.com/repos/dshil/playground/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dshil/playground/statuses/{sha}","languages_url":"https://api.github.com/repos/dshil/playground/languages","stargazers_url":"https://api.github.com/repos/dshil/playground/stargazers","contributors_url":"https://api.github.com/repos/dshil/playground/contributors","subscribers_url":"https://api.github.com/repos/dshil/playground/subscribers","subscription_url":"https://api.github.com/repos/dshil/playground/subscription","commits_url":"https://api.github.com/repos/dshil/playground/commits{/sha}","git_commits_url":"https://api.github.com/repos/dshil/playground/git/commits{/sha}","comments_url":"https://api.github.com/repos/dshil/playground/comments{/number}","issue_comment_url":"https://api.github.com/repos/dshil/playground/issues/comments{/number}","contents_url":"https://api.github.com/repos/dshil/playground/contents/{+path}","compare_url":"https://api.github.com/repos/dshil/playground/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dshil/playground/merges","archive_url":"https://api.github.com/repos/dshil/playground/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dshil/playground/downloads","issues_url":"https://api.github.com/repos/dshil/playground/issues{/number}","pulls_url":"https://api.github.com/repos/dshil/playground/pulls{/number}","milestones_url":"https://api.github.com/repos/dshil/playground/milestones{/number}","notifications_url":"https://api.github.com/repos/dshil/playground/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dshil/playground/labels{/name}","releases_url":"https://api.github.com/repos/dshil/playground/releases{/id}","deployments_url":"https://api.github.com/repos/dshil/playground/deployments","created_at":"2016-09-10T07:23:15Z","updated_at":"2017-03-13T03:19:28Z","pushed_at":"2017-03-20T06:02:36Z","git_url":"git://github.com/dshil/playground.git","ssh_url":"git@github.com:dshil/playground.git","clone_url":"https://github.com/dshil/playground.git","svn_url":"https://github.com/dshil/playground","homepage":"","size":67,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dshil/playground/pulls/25"},"html":{"href":"https://github.com/dshil/playground/pull/25"},"issue":{"href":"https://api.github.com/repos/dshil/playground/issues/25"},"comments":{"href":"https://api.github.com/repos/dshil/playground/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/dshil/playground/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/dshil/playground/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dshil/playground/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/dshil/playground/statuses/b1fa9ef7280639e4a5ed1919ac4697ee57d976a6"}}}}
{"actor":{"display_login":"dshil"}}