{"action":"created","comment":{"url":"https://api.github.com/repos/squid-cache/squid/pulls/comments/174995654","pull_request_review_id":104452735,"id":174995654,"diff_hunk":"@@ -0,0 +1,115 @@\n+/*\n+ * Copyright (C) 1996-2018 The Squid Software Foundation and contributors\n+ *\n+ * Squid software is distributed under GPLv2+ license and includes\n+ * contributions from numerous individuals and organizations.\n+ * Please see the COPYING and CONTRIBUTORS files for details.\n+ */\n+\n+#include \"squid.h\"\n+\n+#include \"CommandLine.h\"\n+\n+static void\n+ResetGetopt(const bool allowStderrWarnings)\n+{\n+    opterr = allowStderrWarnings ? 1 : 0;\n+    // getopt(3) uses global state but resets it if optind is zero\n+    // getopt(3) always skips argv[0], even if optind is zero\n+    optind = 0;\n+}\n+\n+CommandLine::CommandLine(int argC, char *argV[], const char *shortRules, const struct option *longRules):\n+    argv_(),\n+    shortOptions_(xstrdup(shortRules)),\n+    longOptions_()\n+{\n+    assert(argC > 0); // C++ main() requirement that makes our arg0() safe\n+\n+    /* copy argV items */\n+    argv_.reserve(argC+1);\n+    for (int i = 0; i < argC; ++i)\n+        argv_.push_back(xstrdup(argV[i]));\n+    argv_.push_back(nullptr); // POSIX argv \"must be terminated by a null pointer\"\n+\n+    /* copy grammar rules for the long options */\n+    for (auto longOption = longRules; longOption; ++longOption) {\n+        longOptions_.push_back(*longOption);","path":"src/CommandLine.cc","position":37,"original_position":37,"commit_id":"5c1e6d2337cfba000440708e0826cd3390d6a15e","original_commit_id":"5c1e6d2337cfba000440708e0826cd3390d6a15e","user":{"login":"rousskov","id":1084944,"avatar_url":"https://avatars0.githubusercontent.com/u/1084944?v=4","gravatar_id":"","url":"https://api.github.com/users/rousskov","html_url":"https://github.com/rousskov","followers_url":"https://api.github.com/users/rousskov/followers","following_url":"https://api.github.com/users/rousskov/following{/other_user}","gists_url":"https://api.github.com/users/rousskov/gists{/gist_id}","starred_url":"https://api.github.com/users/rousskov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rousskov/subscriptions","organizations_url":"https://api.github.com/users/rousskov/orgs","repos_url":"https://api.github.com/users/rousskov/repos","events_url":"https://api.github.com/users/rousskov/events{/privacy}","received_events_url":"https://api.github.com/users/rousskov/received_events","type":"User","site_admin":false},"body":"Right. Please note that the alternative design does not need a wrapper.","created_at":"2018-03-16T04:32:35Z","updated_at":"2018-03-16T04:32:35Z","html_url":"https://github.com/squid-cache/squid/pull/176#discussion_r174995654","pull_request_url":"https://api.github.com/repos/squid-cache/squid/pulls/176","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/squid-cache/squid/pulls/comments/174995654"},"html":{"href":"https://github.com/squid-cache/squid/pull/176#discussion_r174995654"},"pull_request":{"href":"https://api.github.com/repos/squid-cache/squid/pulls/176"}},"in_reply_to_id":174719098},"pull_request":{"url":"https://api.github.com/repos/squid-cache/squid/pulls/176","id":174644038,"html_url":"https://github.com/squid-cache/squid/pull/176","diff_url":"https://github.com/squid-cache/squid/pull/176.diff","patch_url":"https://github.com/squid-cache/squid/pull/176.patch","issue_url":"https://api.github.com/repos/squid-cache/squid/issues/176","number":176,"state":"open","locked":false,"title":"Do not abuse argv[0] to supply roles and IDs to SMP kids","user":{"login":"eduard-bagdasaryan","id":13069213,"avatar_url":"https://avatars3.githubusercontent.com/u/13069213?v=4","gravatar_id":"","url":"https://api.github.com/users/eduard-bagdasaryan","html_url":"https://github.com/eduard-bagdasaryan","followers_url":"https://api.github.com/users/eduard-bagdasaryan/followers","following_url":"https://api.github.com/users/eduard-bagdasaryan/following{/other_user}","gists_url":"https://api.github.com/users/eduard-bagdasaryan/gists{/gist_id}","starred_url":"https://api.github.com/users/eduard-bagdasaryan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eduard-bagdasaryan/subscriptions","organizations_url":"https://api.github.com/users/eduard-bagdasaryan/orgs","repos_url":"https://api.github.com/users/eduard-bagdasaryan/repos","events_url":"https://api.github.com/users/eduard-bagdasaryan/events{/privacy}","received_events_url":"https://api.github.com/users/eduard-bagdasaryan/received_events","type":"User","site_admin":false},"body":"Use a newly added \"--kid role-ID\" command line option instead. Just like\r\nargv[0], the new option is not meant for direct/human use.\r\n\r\nThis change allows exec(3)-wrapping tools like Valgrind to work with SMP\r\nSquid: When launching kid processes, Valgrind does not pass Squid-formed\r\nargv[0] to kid processes, breaking old kid role and ID detection code.\r\n\r\nThis change does not alter argv[0] of Squid processes. There is nothing\r\nwrong with Squid-formed argv[0] values for Squid kids.\r\n    \r\nAlso added a CommandLine class to support command line parsing without\r\ncode duplication. Squid needs to handle the new --kid option way before\r\nthe old mainParseOptions() handles the other options. The new class also\r\nencapsulates argv manipulations, reducing main.cc pollution.","created_at":"2018-03-13T12:27:23Z","updated_at":"2018-03-16T04:32:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2fa649540adf8273f6948d341ee3deee408762be","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":666339686,"url":"https://api.github.com/repos/squid-cache/squid/labels/S-waiting-for-author","name":"S-waiting-for-author","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/squid-cache/squid/pulls/176/commits","review_comments_url":"https://api.github.com/repos/squid-cache/squid/pulls/176/comments","review_comment_url":"https://api.github.com/repos/squid-cache/squid/pulls/comments{/number}","comments_url":"https://api.github.com/repos/squid-cache/squid/issues/176/comments","statuses_url":"https://api.github.com/repos/squid-cache/squid/statuses/5c1e6d2337cfba000440708e0826cd3390d6a15e","head":{"label":"measurement-factory:SQUID-346-add-kids-option","ref":"SQUID-346-add-kids-option","sha":"5c1e6d2337cfba000440708e0826cd3390d6a15e","user":{"login":"measurement-factory","id":5461029,"avatar_url":"https://avatars1.githubusercontent.com/u/5461029?v=4","gravatar_id":"","url":"https://api.github.com/users/measurement-factory","html_url":"https://github.com/measurement-factory","followers_url":"https://api.github.com/users/measurement-factory/followers","following_url":"https://api.github.com/users/measurement-factory/following{/other_user}","gists_url":"https://api.github.com/users/measurement-factory/gists{/gist_id}","starred_url":"https://api.github.com/users/measurement-factory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/measurement-factory/subscriptions","organizations_url":"https://api.github.com/users/measurement-factory/orgs","repos_url":"https://api.github.com/users/measurement-factory/repos","events_url":"https://api.github.com/users/measurement-factory/events{/privacy}","received_events_url":"https://api.github.com/users/measurement-factory/received_events","type":"Organization","site_admin":false},"repo":{"id":97358214,"name":"squid","full_name":"measurement-factory/squid","owner":{"login":"measurement-factory","id":5461029,"avatar_url":"https://avatars1.githubusercontent.com/u/5461029?v=4","gravatar_id":"","url":"https://api.github.com/users/measurement-factory","html_url":"https://github.com/measurement-factory","followers_url":"https://api.github.com/users/measurement-factory/followers","following_url":"https://api.github.com/users/measurement-factory/following{/other_user}","gists_url":"https://api.github.com/users/measurement-factory/gists{/gist_id}","starred_url":"https://api.github.com/users/measurement-factory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/measurement-factory/subscriptions","organizations_url":"https://api.github.com/users/measurement-factory/orgs","repos_url":"https://api.github.com/users/measurement-factory/repos","events_url":"https://api.github.com/users/measurement-factory/events{/privacy}","received_events_url":"https://api.github.com/users/measurement-factory/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/measurement-factory/squid","description":"Squid Web Proxy Cache","fork":true,"url":"https://api.github.com/repos/measurement-factory/squid","forks_url":"https://api.github.com/repos/measurement-factory/squid/forks","keys_url":"https://api.github.com/repos/measurement-factory/squid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/measurement-factory/squid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/measurement-factory/squid/teams","hooks_url":"https://api.github.com/repos/measurement-factory/squid/hooks","issue_events_url":"https://api.github.com/repos/measurement-factory/squid/issues/events{/number}","events_url":"https://api.github.com/repos/measurement-factory/squid/events","assignees_url":"https://api.github.com/repos/measurement-factory/squid/assignees{/user}","branches_url":"https://api.github.com/repos/measurement-factory/squid/branches{/branch}","tags_url":"https://api.github.com/repos/measurement-factory/squid/tags","blobs_url":"https://api.github.com/repos/measurement-factory/squid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/measurement-factory/squid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/measurement-factory/squid/git/refs{/sha}","trees_url":"https://api.github.com/repos/measurement-factory/squid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/measurement-factory/squid/statuses/{sha}","languages_url":"https://api.github.com/repos/measurement-factory/squid/languages","stargazers_url":"https://api.github.com/repos/measurement-factory/squid/stargazers","contributors_url":"https://api.github.com/repos/measurement-factory/squid/contributors","subscribers_url":"https://api.github.com/repos/measurement-factory/squid/subscribers","subscription_url":"https://api.github.com/repos/measurement-factory/squid/subscription","commits_url":"https://api.github.com/repos/measurement-factory/squid/commits{/sha}","git_commits_url":"https://api.github.com/repos/measurement-factory/squid/git/commits{/sha}","comments_url":"https://api.github.com/repos/measurement-factory/squid/comments{/number}","issue_comment_url":"https://api.github.com/repos/measurement-factory/squid/issues/comments{/number}","contents_url":"https://api.github.com/repos/measurement-factory/squid/contents/{+path}","compare_url":"https://api.github.com/repos/measurement-factory/squid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/measurement-factory/squid/merges","archive_url":"https://api.github.com/repos/measurement-factory/squid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/measurement-factory/squid/downloads","issues_url":"https://api.github.com/repos/measurement-factory/squid/issues{/number}","pulls_url":"https://api.github.com/repos/measurement-factory/squid/pulls{/number}","milestones_url":"https://api.github.com/repos/measurement-factory/squid/milestones{/number}","notifications_url":"https://api.github.com/repos/measurement-factory/squid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/measurement-factory/squid/labels{/name}","releases_url":"https://api.github.com/repos/measurement-factory/squid/releases{/id}","deployments_url":"https://api.github.com/repos/measurement-factory/squid/deployments","created_at":"2017-07-16T03:46:50Z","updated_at":"2017-07-16T03:46:58Z","pushed_at":"2018-03-15T06:39:39Z","git_url":"git://github.com/measurement-factory/squid.git","ssh_url":"git@github.com:measurement-factory/squid.git","clone_url":"https://github.com/measurement-factory/squid.git","svn_url":"https://github.com/measurement-factory/squid","homepage":"http://www.squid-cache.org/","size":170270,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"squid-cache:master","ref":"master","sha":"2db9989c5c4397458ef9ef43f8698844cd9ffcea","user":{"login":"squid-cache","id":363029,"avatar_url":"https://avatars3.githubusercontent.com/u/363029?v=4","gravatar_id":"","url":"https://api.github.com/users/squid-cache","html_url":"https://github.com/squid-cache","followers_url":"https://api.github.com/users/squid-cache/followers","following_url":"https://api.github.com/users/squid-cache/following{/other_user}","gists_url":"https://api.github.com/users/squid-cache/gists{/gist_id}","starred_url":"https://api.github.com/users/squid-cache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/squid-cache/subscriptions","organizations_url":"https://api.github.com/users/squid-cache/orgs","repos_url":"https://api.github.com/users/squid-cache/repos","events_url":"https://api.github.com/users/squid-cache/events{/privacy}","received_events_url":"https://api.github.com/users/squid-cache/received_events","type":"Organization","site_admin":false},"repo":{"id":24519987,"name":"squid","full_name":"squid-cache/squid","owner":{"login":"squid-cache","id":363029,"avatar_url":"https://avatars3.githubusercontent.com/u/363029?v=4","gravatar_id":"","url":"https://api.github.com/users/squid-cache","html_url":"https://github.com/squid-cache","followers_url":"https://api.github.com/users/squid-cache/followers","following_url":"https://api.github.com/users/squid-cache/following{/other_user}","gists_url":"https://api.github.com/users/squid-cache/gists{/gist_id}","starred_url":"https://api.github.com/users/squid-cache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/squid-cache/subscriptions","organizations_url":"https://api.github.com/users/squid-cache/orgs","repos_url":"https://api.github.com/users/squid-cache/repos","events_url":"https://api.github.com/users/squid-cache/events{/privacy}","received_events_url":"https://api.github.com/users/squid-cache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/squid-cache/squid","description":"Squid Web Proxy Cache","fork":false,"url":"https://api.github.com/repos/squid-cache/squid","forks_url":"https://api.github.com/repos/squid-cache/squid/forks","keys_url":"https://api.github.com/repos/squid-cache/squid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/squid-cache/squid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/squid-cache/squid/teams","hooks_url":"https://api.github.com/repos/squid-cache/squid/hooks","issue_events_url":"https://api.github.com/repos/squid-cache/squid/issues/events{/number}","events_url":"https://api.github.com/repos/squid-cache/squid/events","assignees_url":"https://api.github.com/repos/squid-cache/squid/assignees{/user}","branches_url":"https://api.github.com/repos/squid-cache/squid/branches{/branch}","tags_url":"https://api.github.com/repos/squid-cache/squid/tags","blobs_url":"https://api.github.com/repos/squid-cache/squid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/squid-cache/squid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/squid-cache/squid/git/refs{/sha}","trees_url":"https://api.github.com/repos/squid-cache/squid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/squid-cache/squid/statuses/{sha}","languages_url":"https://api.github.com/repos/squid-cache/squid/languages","stargazers_url":"https://api.github.com/repos/squid-cache/squid/stargazers","contributors_url":"https://api.github.com/repos/squid-cache/squid/contributors","subscribers_url":"https://api.github.com/repos/squid-cache/squid/subscribers","subscription_url":"https://api.github.com/repos/squid-cache/squid/subscription","commits_url":"https://api.github.com/repos/squid-cache/squid/commits{/sha}","git_commits_url":"https://api.github.com/repos/squid-cache/squid/git/commits{/sha}","comments_url":"https://api.github.com/repos/squid-cache/squid/comments{/number}","issue_comment_url":"https://api.github.com/repos/squid-cache/squid/issues/comments{/number}","contents_url":"https://api.github.com/repos/squid-cache/squid/contents/{+path}","compare_url":"https://api.github.com/repos/squid-cache/squid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/squid-cache/squid/merges","archive_url":"https://api.github.com/repos/squid-cache/squid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/squid-cache/squid/downloads","issues_url":"https://api.github.com/repos/squid-cache/squid/issues{/number}","pulls_url":"https://api.github.com/repos/squid-cache/squid/pulls{/number}","milestones_url":"https://api.github.com/repos/squid-cache/squid/milestones{/number}","notifications_url":"https://api.github.com/repos/squid-cache/squid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/squid-cache/squid/labels{/name}","releases_url":"https://api.github.com/repos/squid-cache/squid/releases{/id}","deployments_url":"https://api.github.com/repos/squid-cache/squid/deployments","created_at":"2014-09-27T00:59:40Z","updated_at":"2018-03-13T12:40:01Z","pushed_at":"2018-03-15T09:49:32Z","git_url":"git://github.com/squid-cache/squid.git","ssh_url":"git@github.com:squid-cache/squid.git","clone_url":"https://github.com/squid-cache/squid.git","svn_url":"https://github.com/squid-cache/squid","homepage":"http://www.squid-cache.org/","size":161975,"stargazers_count":303,"watchers_count":303,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":119,"mirror_url":null,"archived":false,"open_issues_count":22,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":119,"open_issues":22,"watchers":303,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/squid-cache/squid/pulls/176"},"html":{"href":"https://github.com/squid-cache/squid/pull/176"},"issue":{"href":"https://api.github.com/repos/squid-cache/squid/issues/176"},"comments":{"href":"https://api.github.com/repos/squid-cache/squid/issues/176/comments"},"review_comments":{"href":"https://api.github.com/repos/squid-cache/squid/pulls/176/comments"},"review_comment":{"href":"https://api.github.com/repos/squid-cache/squid/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/squid-cache/squid/pulls/176/commits"},"statuses":{"href":"https://api.github.com/repos/squid-cache/squid/statuses/5c1e6d2337cfba000440708e0826cd3390d6a15e"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"rousskov"}}