{"action":"created","comment":{"url":"https://api.github.com/repos/chocolatey/choco/pulls/comments/62346740","id":62346740,"diff_hunk":"@@ -116,6 +116,76 @@ Elevating Permissions and running [`\"$exeToRun`\" $wrappedStatements]. This may t\n   if ($process.StartInfo.RedirectStandardError) { $process.BeginErrorReadLine() }\r\n   $process.WaitForExit()  \r\n \r\n+  # This handles installers which exit immediately, and spawn lingering children tasks\r\n+  # which may be carrying on additional installation tasks.\r\n+  #\r\n+  # Few installers spawn child processes which outlive the parent process. So,\r\n+  # let's monitor the exit of these children (and any of their children).\r\n+  #\r\n+  # Implementation inspired by:\r\n+  # http://powershell.com/cs/blogs/tobias/archive/2012/05/09/managing-child-processes.aspx\r\n+  #\r\n+  # TODO: Will some installers provide meaningful exit-codes here?\r\n+  #\r\n+  # BEGIN handling of process children\r\n+    function Get-ProcessChildren {\r\n+    param(\r\n+      $Id\r\n+    )\r\n+\r\n+      Write-Debug \"Searching for any active children to process ($($Id))\"\r\n+\r\n+      $children = Get-WmiObject -Class Win32_Process -Filter \"ParentProcessID=$($Id)\"\r\n+\r\n+      $result = $null\r\n+\r\n+      if ( $children ) {\r\n+        # filter to only include results with ProcessId\r\n+        $children = $children | Where-Object { $_.ProcessId -ne $null }\r\n+\r\n+        # add children to result\r\n+        $result = @( $children )\r\n+\r\n+        # recursively collect grandchildren processes\r\n+        foreach ( $child in $children ) {\r\n+\r\n+          Write-Debug \"Found active child process ($($child.ProcessId))\"\r\n+\r\n+          $grandchildren = Get-ProcessChildren -Id $child.ProcessId\r\n+\r\n+          # add grandchildren to result\r\n+          $result += @( $grandchildren )\r\n+\r\n+        }\r\n+\r\n+      }\r\n+\r\n+      Return $result\r\n+\r\n+    }\r\n+\r\n+    $children = Get-ProcessChildren -Id $process.Id\r\n+\r\n+    Write-Debug \"Children processes: $($children)\"\r\n+\r\n+    foreach ($child in $children)\r\n+    {\r\n+      try {\r\n+\r\n+        if ( $child.ProcessId ) {\r\n+\r\n+          Write-Debug \"Waiting for child process ($($child.Processid))\"\r\n+\r\n+          Wait-Process -Id $child.ProcessId\r","path":"src/chocolatey.resources/helpers/functions/Start-ChocolateyProcessAsAdmin.ps1","position":64,"original_position":64,"commit_id":"f652147f9e5395de6d87409826ca8d9e65ff5d5e","original_commit_id":"f652147f9e5395de6d87409826ca8d9e65ff5d5e","user":{"login":"ferventcoder","id":63502,"avatar_url":"https://avatars.githubusercontent.com/u/63502?v=3","gravatar_id":"","url":"https://api.github.com/users/ferventcoder","html_url":"https://github.com/ferventcoder","followers_url":"https://api.github.com/users/ferventcoder/followers","following_url":"https://api.github.com/users/ferventcoder/following{/other_user}","gists_url":"https://api.github.com/users/ferventcoder/gists{/gist_id}","starred_url":"https://api.github.com/users/ferventcoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ferventcoder/subscriptions","organizations_url":"https://api.github.com/users/ferventcoder/orgs","repos_url":"https://api.github.com/users/ferventcoder/repos","events_url":"https://api.github.com/users/ferventcoder/events{/privacy}","received_events_url":"https://api.github.com/users/ferventcoder/received_events","type":"User","site_admin":false},"body":"This is known to cause issues with PowerShell v3.","created_at":"2016-05-06T15:36:03Z","updated_at":"2016-05-06T15:36:03Z","html_url":"https://github.com/chocolatey/choco/pull/726#discussion_r62346740","pull_request_url":"https://api.github.com/repos/chocolatey/choco/pulls/726","_links":{"self":{"href":"https://api.github.com/repos/chocolatey/choco/pulls/comments/62346740"},"html":{"href":"https://github.com/chocolatey/choco/pull/726#discussion_r62346740"},"pull_request":{"href":"https://api.github.com/repos/chocolatey/choco/pulls/726"}}},"pull_request":{"url":"https://api.github.com/repos/chocolatey/choco/pulls/726","id":69167090,"html_url":"https://github.com/chocolatey/choco/pull/726","diff_url":"https://github.com/chocolatey/choco/pull/726.diff","patch_url":"https://github.com/chocolatey/choco/pull/726.patch","issue_url":"https://api.github.com/repos/chocolatey/choco/issues/726","number":726,"state":"open","locked":false,"title":"(GH-725) Wait for child processes to complete","user":{"login":"dekalinowski","id":8686494,"avatar_url":"https://avatars.githubusercontent.com/u/8686494?v=3","gravatar_id":"","url":"https://api.github.com/users/dekalinowski","html_url":"https://github.com/dekalinowski","followers_url":"https://api.github.com/users/dekalinowski/followers","following_url":"https://api.github.com/users/dekalinowski/following{/other_user}","gists_url":"https://api.github.com/users/dekalinowski/gists{/gist_id}","starred_url":"https://api.github.com/users/dekalinowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dekalinowski/subscriptions","organizations_url":"https://api.github.com/users/dekalinowski/orgs","repos_url":"https://api.github.com/users/dekalinowski/repos","events_url":"https://api.github.com/users/dekalinowski/events{/privacy}","received_events_url":"https://api.github.com/users/dekalinowski/received_events","type":"User","site_admin":false},"body":"#725\r\n\r\nFix for installers which exit immediately, and spawn lingering child\r\nprocesses, which may carry on additional installation tasks.\r\n\r\nSolution first queries for child processes whose parent process ID\r\nmatches the installer process. Then, recursively queries for other\r\nactive processes related to those children. Finally, wait for each\r\nprocess to exit.","created_at":"2016-05-06T15:25:26Z","updated_at":"2016-05-06T15:36:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"879d9797ed68092f4909eb2804af8d657714c1fa","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/chocolatey/choco/pulls/726/commits","review_comments_url":"https://api.github.com/repos/chocolatey/choco/pulls/726/comments","review_comment_url":"https://api.github.com/repos/chocolatey/choco/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chocolatey/choco/issues/726/comments","statuses_url":"https://api.github.com/repos/chocolatey/choco/statuses/f652147f9e5395de6d87409826ca8d9e65ff5d5e","head":{"label":"dekalinowski:feature/wait_for_child_process","ref":"feature/wait_for_child_process","sha":"f652147f9e5395de6d87409826ca8d9e65ff5d5e","user":{"login":"dekalinowski","id":8686494,"avatar_url":"https://avatars.githubusercontent.com/u/8686494?v=3","gravatar_id":"","url":"https://api.github.com/users/dekalinowski","html_url":"https://github.com/dekalinowski","followers_url":"https://api.github.com/users/dekalinowski/followers","following_url":"https://api.github.com/users/dekalinowski/following{/other_user}","gists_url":"https://api.github.com/users/dekalinowski/gists{/gist_id}","starred_url":"https://api.github.com/users/dekalinowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dekalinowski/subscriptions","organizations_url":"https://api.github.com/users/dekalinowski/orgs","repos_url":"https://api.github.com/users/dekalinowski/repos","events_url":"https://api.github.com/users/dekalinowski/events{/privacy}","received_events_url":"https://api.github.com/users/dekalinowski/received_events","type":"User","site_admin":false},"repo":{"id":49836475,"name":"choco","full_name":"dekalinowski/choco","owner":{"login":"dekalinowski","id":8686494,"avatar_url":"https://avatars.githubusercontent.com/u/8686494?v=3","gravatar_id":"","url":"https://api.github.com/users/dekalinowski","html_url":"https://github.com/dekalinowski","followers_url":"https://api.github.com/users/dekalinowski/followers","following_url":"https://api.github.com/users/dekalinowski/following{/other_user}","gists_url":"https://api.github.com/users/dekalinowski/gists{/gist_id}","starred_url":"https://api.github.com/users/dekalinowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dekalinowski/subscriptions","organizations_url":"https://api.github.com/users/dekalinowski/orgs","repos_url":"https://api.github.com/users/dekalinowski/repos","events_url":"https://api.github.com/users/dekalinowski/events{/privacy}","received_events_url":"https://api.github.com/users/dekalinowski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dekalinowski/choco","description":"Chocolatey CLI","fork":true,"url":"https://api.github.com/repos/dekalinowski/choco","forks_url":"https://api.github.com/repos/dekalinowski/choco/forks","keys_url":"https://api.github.com/repos/dekalinowski/choco/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dekalinowski/choco/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dekalinowski/choco/teams","hooks_url":"https://api.github.com/repos/dekalinowski/choco/hooks","issue_events_url":"https://api.github.com/repos/dekalinowski/choco/issues/events{/number}","events_url":"https://api.github.com/repos/dekalinowski/choco/events","assignees_url":"https://api.github.com/repos/dekalinowski/choco/assignees{/user}","branches_url":"https://api.github.com/repos/dekalinowski/choco/branches{/branch}","tags_url":"https://api.github.com/repos/dekalinowski/choco/tags","blobs_url":"https://api.github.com/repos/dekalinowski/choco/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dekalinowski/choco/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dekalinowski/choco/git/refs{/sha}","trees_url":"https://api.github.com/repos/dekalinowski/choco/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dekalinowski/choco/statuses/{sha}","languages_url":"https://api.github.com/repos/dekalinowski/choco/languages","stargazers_url":"https://api.github.com/repos/dekalinowski/choco/stargazers","contributors_url":"https://api.github.com/repos/dekalinowski/choco/contributors","subscribers_url":"https://api.github.com/repos/dekalinowski/choco/subscribers","subscription_url":"https://api.github.com/repos/dekalinowski/choco/subscription","commits_url":"https://api.github.com/repos/dekalinowski/choco/commits{/sha}","git_commits_url":"https://api.github.com/repos/dekalinowski/choco/git/commits{/sha}","comments_url":"https://api.github.com/repos/dekalinowski/choco/comments{/number}","issue_comment_url":"https://api.github.com/repos/dekalinowski/choco/issues/comments{/number}","contents_url":"https://api.github.com/repos/dekalinowski/choco/contents/{+path}","compare_url":"https://api.github.com/repos/dekalinowski/choco/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dekalinowski/choco/merges","archive_url":"https://api.github.com/repos/dekalinowski/choco/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dekalinowski/choco/downloads","issues_url":"https://api.github.com/repos/dekalinowski/choco/issues{/number}","pulls_url":"https://api.github.com/repos/dekalinowski/choco/pulls{/number}","milestones_url":"https://api.github.com/repos/dekalinowski/choco/milestones{/number}","notifications_url":"https://api.github.com/repos/dekalinowski/choco/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dekalinowski/choco/labels{/name}","releases_url":"https://api.github.com/repos/dekalinowski/choco/releases{/id}","deployments_url":"https://api.github.com/repos/dekalinowski/choco/deployments","created_at":"2016-01-17T21:29:28Z","updated_at":"2016-01-17T21:29:30Z","pushed_at":"2016-05-06T15:14:50Z","git_url":"git://github.com/dekalinowski/choco.git","ssh_url":"git@github.com:dekalinowski/choco.git","clone_url":"https://github.com/dekalinowski/choco.git","svn_url":"https://github.com/dekalinowski/choco","homepage":"","size":13719,"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":"chocolatey:master","ref":"master","sha":"b8dced9412948f0c93b0cb0f165f44d11eeaa5f1","user":{"login":"chocolatey","id":811025,"avatar_url":"https://avatars.githubusercontent.com/u/811025?v=3","gravatar_id":"","url":"https://api.github.com/users/chocolatey","html_url":"https://github.com/chocolatey","followers_url":"https://api.github.com/users/chocolatey/followers","following_url":"https://api.github.com/users/chocolatey/following{/other_user}","gists_url":"https://api.github.com/users/chocolatey/gists{/gist_id}","starred_url":"https://api.github.com/users/chocolatey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chocolatey/subscriptions","organizations_url":"https://api.github.com/users/chocolatey/orgs","repos_url":"https://api.github.com/users/chocolatey/repos","events_url":"https://api.github.com/users/chocolatey/events{/privacy}","received_events_url":"https://api.github.com/users/chocolatey/received_events","type":"Organization","site_admin":false},"repo":{"id":28647218,"name":"choco","full_name":"chocolatey/choco","owner":{"login":"chocolatey","id":811025,"avatar_url":"https://avatars.githubusercontent.com/u/811025?v=3","gravatar_id":"","url":"https://api.github.com/users/chocolatey","html_url":"https://github.com/chocolatey","followers_url":"https://api.github.com/users/chocolatey/followers","following_url":"https://api.github.com/users/chocolatey/following{/other_user}","gists_url":"https://api.github.com/users/chocolatey/gists{/gist_id}","starred_url":"https://api.github.com/users/chocolatey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chocolatey/subscriptions","organizations_url":"https://api.github.com/users/chocolatey/orgs","repos_url":"https://api.github.com/users/chocolatey/repos","events_url":"https://api.github.com/users/chocolatey/events{/privacy}","received_events_url":"https://api.github.com/users/chocolatey/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chocolatey/choco","description":"Chocolatey CLI","fork":false,"url":"https://api.github.com/repos/chocolatey/choco","forks_url":"https://api.github.com/repos/chocolatey/choco/forks","keys_url":"https://api.github.com/repos/chocolatey/choco/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chocolatey/choco/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chocolatey/choco/teams","hooks_url":"https://api.github.com/repos/chocolatey/choco/hooks","issue_events_url":"https://api.github.com/repos/chocolatey/choco/issues/events{/number}","events_url":"https://api.github.com/repos/chocolatey/choco/events","assignees_url":"https://api.github.com/repos/chocolatey/choco/assignees{/user}","branches_url":"https://api.github.com/repos/chocolatey/choco/branches{/branch}","tags_url":"https://api.github.com/repos/chocolatey/choco/tags","blobs_url":"https://api.github.com/repos/chocolatey/choco/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chocolatey/choco/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chocolatey/choco/git/refs{/sha}","trees_url":"https://api.github.com/repos/chocolatey/choco/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chocolatey/choco/statuses/{sha}","languages_url":"https://api.github.com/repos/chocolatey/choco/languages","stargazers_url":"https://api.github.com/repos/chocolatey/choco/stargazers","contributors_url":"https://api.github.com/repos/chocolatey/choco/contributors","subscribers_url":"https://api.github.com/repos/chocolatey/choco/subscribers","subscription_url":"https://api.github.com/repos/chocolatey/choco/subscription","commits_url":"https://api.github.com/repos/chocolatey/choco/commits{/sha}","git_commits_url":"https://api.github.com/repos/chocolatey/choco/git/commits{/sha}","comments_url":"https://api.github.com/repos/chocolatey/choco/comments{/number}","issue_comment_url":"https://api.github.com/repos/chocolatey/choco/issues/comments{/number}","contents_url":"https://api.github.com/repos/chocolatey/choco/contents/{+path}","compare_url":"https://api.github.com/repos/chocolatey/choco/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chocolatey/choco/merges","archive_url":"https://api.github.com/repos/chocolatey/choco/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chocolatey/choco/downloads","issues_url":"https://api.github.com/repos/chocolatey/choco/issues{/number}","pulls_url":"https://api.github.com/repos/chocolatey/choco/pulls{/number}","milestones_url":"https://api.github.com/repos/chocolatey/choco/milestones{/number}","notifications_url":"https://api.github.com/repos/chocolatey/choco/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chocolatey/choco/labels{/name}","releases_url":"https://api.github.com/repos/chocolatey/choco/releases{/id}","deployments_url":"https://api.github.com/repos/chocolatey/choco/deployments","created_at":"2014-12-30T22:12:11Z","updated_at":"2016-05-06T13:56:37Z","pushed_at":"2016-05-06T15:25:26Z","git_url":"git://github.com/chocolatey/choco.git","ssh_url":"git@github.com:chocolatey/choco.git","clone_url":"https://github.com/chocolatey/choco.git","svn_url":"https://github.com/chocolatey/choco","homepage":"","size":15410,"stargazers_count":1937,"watchers_count":1937,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":236,"mirror_url":null,"open_issues_count":255,"forks":236,"open_issues":255,"watchers":1937,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chocolatey/choco/pulls/726"},"html":{"href":"https://github.com/chocolatey/choco/pull/726"},"issue":{"href":"https://api.github.com/repos/chocolatey/choco/issues/726"},"comments":{"href":"https://api.github.com/repos/chocolatey/choco/issues/726/comments"},"review_comments":{"href":"https://api.github.com/repos/chocolatey/choco/pulls/726/comments"},"review_comment":{"href":"https://api.github.com/repos/chocolatey/choco/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chocolatey/choco/pulls/726/commits"},"statuses":{"href":"https://api.github.com/repos/chocolatey/choco/statuses/f652147f9e5395de6d87409826ca8d9e65ff5d5e"}}}}