{"action":"created","comment":{"url":"https://api.github.com/repos/r-lib/processx/pulls/comments/204449698","pull_request_review_id":139521669,"id":204449698,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNDQ0OTY5OA==","diff_hunk":"@@ -0,0 +1,255 @@\n+\n+#include <Rinternals.h>\n+\n+#include \"processx.h\"\n+\n+#ifdef _WIN32\n+\n+#include <windows.h>\n+\n+double processx__create_time(HANDLE process) {\n+  long long   ll, secs, nsecs;\n+  FILETIME    ftCreate, ftExit, ftKernel, ftUser;\n+\n+  if (! GetProcessTimes(process, &ftCreate, &ftExit, &ftKernel, &ftUser)) {\n+    if (GetLastError() == ERROR_ACCESS_DENIED) {\n+      // usually means the process has died\n+      return 0.0;\n+    } else {\n+      return 0.0;\n+    }\n+  }\n+\n+  ll = ((LONGLONG) ftCreate.dwHighDateTime) << 32;\n+  ll += ftCreate.dwLowDateTime - 116444736000000000LL;\n+  secs = ll / 10000000;\n+  nsecs = ll % 10000000;\n+  return (double) secs + ((double) nsecs) / 10000000;\n+}\n+\n+#endif\n+\n+#ifdef __linux__\n+\n+#include <sys/sysinfo.h>\n+#include <unistd.h>\n+\n+int processx__read_file(const char *path, char **buffer, size_t buffer_size) {\n+  int fd = -1;\n+  ssize_t ret;\n+  char *ptr;\n+  size_t rem_size = buffer_size;\n+\n+  *buffer = 0;\n+\n+  fd = open(path, O_RDONLY);\n+  if (fd == -1) goto error;\n+\n+  ptr = *buffer = R_alloc(buffer_size, 1);\n+  if (!*buffer) goto error;\n+\n+  do {\n+    if (rem_size == 0) {\n+      *buffer = S_realloc(*buffer, buffer_size * 2, buffer_size, 1);","path":"src/create-time.c","position":53,"original_position":53,"commit_id":"10bc97761aeb821d3fe554a48bc0d879ea3a2655","original_commit_id":"10bc97761aeb821d3fe554a48bc0d879ea3a2655","user":{"login":"gaborcsardi","id":660288,"node_id":"MDQ6VXNlcjY2MDI4OA==","avatar_url":"https://avatars3.githubusercontent.com/u/660288?v=4","gravatar_id":"","url":"https://api.github.com/users/gaborcsardi","html_url":"https://github.com/gaborcsardi","followers_url":"https://api.github.com/users/gaborcsardi/followers","following_url":"https://api.github.com/users/gaborcsardi/following{/other_user}","gists_url":"https://api.github.com/users/gaborcsardi/gists{/gist_id}","starred_url":"https://api.github.com/users/gaborcsardi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gaborcsardi/subscriptions","organizations_url":"https://api.github.com/users/gaborcsardi/orgs","repos_url":"https://api.github.com/users/gaborcsardi/repos","events_url":"https://api.github.com/users/gaborcsardi/events{/privacy}","received_events_url":"https://api.github.com/users/gaborcsardi/received_events","type":"User","site_admin":false},"body":"You can't do that with files in `/proc`, their size is not known. Based on my quick test, you also cannot seek to the end in them. They essentially behave like character  devices AFAICT.","created_at":"2018-07-23T15:38:06Z","updated_at":"2018-07-23T15:53:09Z","html_url":"https://github.com/r-lib/processx/pull/143#discussion_r204449698","pull_request_url":"https://api.github.com/repos/r-lib/processx/pulls/143","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/r-lib/processx/pulls/comments/204449698"},"html":{"href":"https://github.com/r-lib/processx/pull/143#discussion_r204449698"},"pull_request":{"href":"https://api.github.com/repos/r-lib/processx/pulls/143"}},"in_reply_to_id":204421551},"pull_request":{"url":"https://api.github.com/repos/r-lib/processx/pulls/143","id":203223656,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzMjIzNjU2","html_url":"https://github.com/r-lib/processx/pull/143","diff_url":"https://github.com/r-lib/processx/pull/143.diff","patch_url":"https://github.com/r-lib/processx/pull/143.patch","issue_url":"https://api.github.com/repos/r-lib/processx/issues/143","number":143,"state":"open","locked":false,"title":"Cleanup process tree","user":{"login":"gaborcsardi","id":660288,"node_id":"MDQ6VXNlcjY2MDI4OA==","avatar_url":"https://avatars3.githubusercontent.com/u/660288?v=4","gravatar_id":"","url":"https://api.github.com/users/gaborcsardi","html_url":"https://github.com/gaborcsardi","followers_url":"https://api.github.com/users/gaborcsardi/followers","following_url":"https://api.github.com/users/gaborcsardi/following{/other_user}","gists_url":"https://api.github.com/users/gaborcsardi/gists{/gist_id}","starred_url":"https://api.github.com/users/gaborcsardi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gaborcsardi/subscriptions","organizations_url":"https://api.github.com/users/gaborcsardi/orgs","repos_url":"https://api.github.com/users/gaborcsardi/repos","events_url":"https://api.github.com/users/gaborcsardi/events{/privacy}","received_events_url":"https://api.github.com/users/gaborcsardi/received_events","type":"User","site_admin":false},"body":"Every processx process `p` is marked with an environment variable that has a random part and a time stamp. Importantly, this variable is _not_ set  in the current process, that would lead to having it set in other, non-processx child processes, eg. started by RStudio.\r\n\r\nThis env var is then inherited by all processes in the process tree rooted at `p`, even if some processes  in the tree are orphaned. (In theory processes could opt out and unset the env var, but we don't anticipate this happening very often.)\r\n\r\n`kill_tree()` uses this  env var, and the (internal) ps package function `ps_kill_tree` to clean up the whole tree.\r\n\r\nCloses #139.\r\n\r\nEDIT:  some more notes:\r\n\r\n- Only Windows, macOS and Linux are supported, because these are the systems for which _ps_ can  read out environment variables from arbitrary processes. On unsupported platforms `kill_tree()` fails with `\"not_implemented\"`.\r\n- _ps_ is currently optional, should we just import it? It has no hard dependencies.\r\n- `kill_tree()` returns data  about the killed processes, I'll add that to the docs in a minute.","created_at":"2018-07-23T13:43:01Z","updated_at":"2018-07-23T15:53:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8bd0625d82e590c9bc7602be83359e5045a9af80","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/r-lib/processx/pulls/143/commits","review_comments_url":"https://api.github.com/repos/r-lib/processx/pulls/143/comments","review_comment_url":"https://api.github.com/repos/r-lib/processx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/r-lib/processx/issues/143/comments","statuses_url":"https://api.github.com/repos/r-lib/processx/statuses/10bc97761aeb821d3fe554a48bc0d879ea3a2655","head":{"label":"r-lib:featue/kill-tree","ref":"featue/kill-tree","sha":"10bc97761aeb821d3fe554a48bc0d879ea3a2655","user":{"login":"r-lib","id":22618716,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyNjE4NzE2","avatar_url":"https://avatars0.githubusercontent.com/u/22618716?v=4","gravatar_id":"","url":"https://api.github.com/users/r-lib","html_url":"https://github.com/r-lib","followers_url":"https://api.github.com/users/r-lib/followers","following_url":"https://api.github.com/users/r-lib/following{/other_user}","gists_url":"https://api.github.com/users/r-lib/gists{/gist_id}","starred_url":"https://api.github.com/users/r-lib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r-lib/subscriptions","organizations_url":"https://api.github.com/users/r-lib/orgs","repos_url":"https://api.github.com/users/r-lib/repos","events_url":"https://api.github.com/users/r-lib/events{/privacy}","received_events_url":"https://api.github.com/users/r-lib/received_events","type":"Organization","site_admin":false},"repo":{"id":66083698,"node_id":"MDEwOlJlcG9zaXRvcnk2NjA4MzY5OA==","name":"processx","full_name":"r-lib/processx","owner":{"login":"r-lib","id":22618716,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyNjE4NzE2","avatar_url":"https://avatars0.githubusercontent.com/u/22618716?v=4","gravatar_id":"","url":"https://api.github.com/users/r-lib","html_url":"https://github.com/r-lib","followers_url":"https://api.github.com/users/r-lib/followers","following_url":"https://api.github.com/users/r-lib/following{/other_user}","gists_url":"https://api.github.com/users/r-lib/gists{/gist_id}","starred_url":"https://api.github.com/users/r-lib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r-lib/subscriptions","organizations_url":"https://api.github.com/users/r-lib/orgs","repos_url":"https://api.github.com/users/r-lib/repos","events_url":"https://api.github.com/users/r-lib/events{/privacy}","received_events_url":"https://api.github.com/users/r-lib/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/r-lib/processx","description":"Execute and Control System Processes from R","fork":false,"url":"https://api.github.com/repos/r-lib/processx","forks_url":"https://api.github.com/repos/r-lib/processx/forks","keys_url":"https://api.github.com/repos/r-lib/processx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/r-lib/processx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/r-lib/processx/teams","hooks_url":"https://api.github.com/repos/r-lib/processx/hooks","issue_events_url":"https://api.github.com/repos/r-lib/processx/issues/events{/number}","events_url":"https://api.github.com/repos/r-lib/processx/events","assignees_url":"https://api.github.com/repos/r-lib/processx/assignees{/user}","branches_url":"https://api.github.com/repos/r-lib/processx/branches{/branch}","tags_url":"https://api.github.com/repos/r-lib/processx/tags","blobs_url":"https://api.github.com/repos/r-lib/processx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/r-lib/processx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/r-lib/processx/git/refs{/sha}","trees_url":"https://api.github.com/repos/r-lib/processx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/r-lib/processx/statuses/{sha}","languages_url":"https://api.github.com/repos/r-lib/processx/languages","stargazers_url":"https://api.github.com/repos/r-lib/processx/stargazers","contributors_url":"https://api.github.com/repos/r-lib/processx/contributors","subscribers_url":"https://api.github.com/repos/r-lib/processx/subscribers","subscription_url":"https://api.github.com/repos/r-lib/processx/subscription","commits_url":"https://api.github.com/repos/r-lib/processx/commits{/sha}","git_commits_url":"https://api.github.com/repos/r-lib/processx/git/commits{/sha}","comments_url":"https://api.github.com/repos/r-lib/processx/comments{/number}","issue_comment_url":"https://api.github.com/repos/r-lib/processx/issues/comments{/number}","contents_url":"https://api.github.com/repos/r-lib/processx/contents/{+path}","compare_url":"https://api.github.com/repos/r-lib/processx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/r-lib/processx/merges","archive_url":"https://api.github.com/repos/r-lib/processx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/r-lib/processx/downloads","issues_url":"https://api.github.com/repos/r-lib/processx/issues{/number}","pulls_url":"https://api.github.com/repos/r-lib/processx/pulls{/number}","milestones_url":"https://api.github.com/repos/r-lib/processx/milestones{/number}","notifications_url":"https://api.github.com/repos/r-lib/processx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/r-lib/processx/labels{/name}","releases_url":"https://api.github.com/repos/r-lib/processx/releases{/id}","deployments_url":"https://api.github.com/repos/r-lib/processx/deployments","created_at":"2016-08-19T13:18:57Z","updated_at":"2018-07-23T10:15:33Z","pushed_at":"2018-07-23T14:02:02Z","git_url":"git://github.com/r-lib/processx.git","ssh_url":"git@github.com:r-lib/processx.git","clone_url":"https://github.com/r-lib/processx.git","svn_url":"https://github.com/r-lib/processx","homepage":"https://processx.r-lib.org/","size":859,"stargazers_count":104,"watchers_count":104,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":15,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":15,"open_issues":9,"watchers":104,"default_branch":"master"}},"base":{"label":"r-lib:master","ref":"master","sha":"f7243ff497fce070b55866dc6d2dd132c35c6e7b","user":{"login":"r-lib","id":22618716,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyNjE4NzE2","avatar_url":"https://avatars0.githubusercontent.com/u/22618716?v=4","gravatar_id":"","url":"https://api.github.com/users/r-lib","html_url":"https://github.com/r-lib","followers_url":"https://api.github.com/users/r-lib/followers","following_url":"https://api.github.com/users/r-lib/following{/other_user}","gists_url":"https://api.github.com/users/r-lib/gists{/gist_id}","starred_url":"https://api.github.com/users/r-lib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r-lib/subscriptions","organizations_url":"https://api.github.com/users/r-lib/orgs","repos_url":"https://api.github.com/users/r-lib/repos","events_url":"https://api.github.com/users/r-lib/events{/privacy}","received_events_url":"https://api.github.com/users/r-lib/received_events","type":"Organization","site_admin":false},"repo":{"id":66083698,"node_id":"MDEwOlJlcG9zaXRvcnk2NjA4MzY5OA==","name":"processx","full_name":"r-lib/processx","owner":{"login":"r-lib","id":22618716,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyNjE4NzE2","avatar_url":"https://avatars0.githubusercontent.com/u/22618716?v=4","gravatar_id":"","url":"https://api.github.com/users/r-lib","html_url":"https://github.com/r-lib","followers_url":"https://api.github.com/users/r-lib/followers","following_url":"https://api.github.com/users/r-lib/following{/other_user}","gists_url":"https://api.github.com/users/r-lib/gists{/gist_id}","starred_url":"https://api.github.com/users/r-lib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r-lib/subscriptions","organizations_url":"https://api.github.com/users/r-lib/orgs","repos_url":"https://api.github.com/users/r-lib/repos","events_url":"https://api.github.com/users/r-lib/events{/privacy}","received_events_url":"https://api.github.com/users/r-lib/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/r-lib/processx","description":"Execute and Control System Processes from R","fork":false,"url":"https://api.github.com/repos/r-lib/processx","forks_url":"https://api.github.com/repos/r-lib/processx/forks","keys_url":"https://api.github.com/repos/r-lib/processx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/r-lib/processx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/r-lib/processx/teams","hooks_url":"https://api.github.com/repos/r-lib/processx/hooks","issue_events_url":"https://api.github.com/repos/r-lib/processx/issues/events{/number}","events_url":"https://api.github.com/repos/r-lib/processx/events","assignees_url":"https://api.github.com/repos/r-lib/processx/assignees{/user}","branches_url":"https://api.github.com/repos/r-lib/processx/branches{/branch}","tags_url":"https://api.github.com/repos/r-lib/processx/tags","blobs_url":"https://api.github.com/repos/r-lib/processx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/r-lib/processx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/r-lib/processx/git/refs{/sha}","trees_url":"https://api.github.com/repos/r-lib/processx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/r-lib/processx/statuses/{sha}","languages_url":"https://api.github.com/repos/r-lib/processx/languages","stargazers_url":"https://api.github.com/repos/r-lib/processx/stargazers","contributors_url":"https://api.github.com/repos/r-lib/processx/contributors","subscribers_url":"https://api.github.com/repos/r-lib/processx/subscribers","subscription_url":"https://api.github.com/repos/r-lib/processx/subscription","commits_url":"https://api.github.com/repos/r-lib/processx/commits{/sha}","git_commits_url":"https://api.github.com/repos/r-lib/processx/git/commits{/sha}","comments_url":"https://api.github.com/repos/r-lib/processx/comments{/number}","issue_comment_url":"https://api.github.com/repos/r-lib/processx/issues/comments{/number}","contents_url":"https://api.github.com/repos/r-lib/processx/contents/{+path}","compare_url":"https://api.github.com/repos/r-lib/processx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/r-lib/processx/merges","archive_url":"https://api.github.com/repos/r-lib/processx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/r-lib/processx/downloads","issues_url":"https://api.github.com/repos/r-lib/processx/issues{/number}","pulls_url":"https://api.github.com/repos/r-lib/processx/pulls{/number}","milestones_url":"https://api.github.com/repos/r-lib/processx/milestones{/number}","notifications_url":"https://api.github.com/repos/r-lib/processx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/r-lib/processx/labels{/name}","releases_url":"https://api.github.com/repos/r-lib/processx/releases{/id}","deployments_url":"https://api.github.com/repos/r-lib/processx/deployments","created_at":"2016-08-19T13:18:57Z","updated_at":"2018-07-23T10:15:33Z","pushed_at":"2018-07-23T14:02:02Z","git_url":"git://github.com/r-lib/processx.git","ssh_url":"git@github.com:r-lib/processx.git","clone_url":"https://github.com/r-lib/processx.git","svn_url":"https://github.com/r-lib/processx","homepage":"https://processx.r-lib.org/","size":859,"stargazers_count":104,"watchers_count":104,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":15,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":15,"open_issues":9,"watchers":104,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/r-lib/processx/pulls/143"},"html":{"href":"https://github.com/r-lib/processx/pull/143"},"issue":{"href":"https://api.github.com/repos/r-lib/processx/issues/143"},"comments":{"href":"https://api.github.com/repos/r-lib/processx/issues/143/comments"},"review_comments":{"href":"https://api.github.com/repos/r-lib/processx/pulls/143/comments"},"review_comment":{"href":"https://api.github.com/repos/r-lib/processx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/r-lib/processx/pulls/143/commits"},"statuses":{"href":"https://api.github.com/repos/r-lib/processx/statuses/10bc97761aeb821d3fe554a48bc0d879ea3a2655"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"gaborcsardi"}}