{"action":"created","comment":{"url":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments/205721782","pull_request_review_id":141048623,"id":205721782,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNTcyMTc4Mg==","diff_hunk":"@@ -117,14 +117,31 @@ class Process\n   # *run_hooks* should ALWAYS be `true` unless `exec` is used immediately after fork.\n   # Channels, `IO` and other will not work reliably if *run_hooks* is `false`.\n   protected def self.fork_internal(run_hooks : Bool = true)\n-    pid = LibC.fork\n-    case pid\n+    newmask = uninitialized LibC::SigsetT\n+    oldmask = uninitialized LibC::SigsetT\n+\n+    LibC.sigfillset(pointerof(newmask))\n+    ret = LibC.pthread_sigmask(LibC::SIG_SETMASK, pointerof(newmask), pointerof(oldmask))\n+    raise Errno.new(\"Failed to disable signals\") unless ret == 0\n+\n+    case pid = LibC.fork\n     when 0\n+      # child:\n       pid = nil\n-      Process.after_fork_child_callbacks.each(&.call) if run_hooks\n+      if run_hooks\n+        Process.after_fork_child_callbacks.each(&.call)\n+        LibC.pthread_sigmask(LibC::SIG_SETMASK, pointerof(oldmask), nil)\n+      end","path":"src/process.cr","position":21,"original_position":21,"commit_id":"87e6430be9da4006163c4cf72c94ad1f0c474c85","original_commit_id":"87e6430be9da4006163c4cf72c94ad1f0c474c85","user":{"login":"forksaber","id":1130011,"node_id":"MDQ6VXNlcjExMzAwMTE=","avatar_url":"https://avatars1.githubusercontent.com/u/1130011?v=4","gravatar_id":"","url":"https://api.github.com/users/forksaber","html_url":"https://github.com/forksaber","followers_url":"https://api.github.com/users/forksaber/followers","following_url":"https://api.github.com/users/forksaber/following{/other_user}","gists_url":"https://api.github.com/users/forksaber/gists{/gist_id}","starred_url":"https://api.github.com/users/forksaber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/forksaber/subscriptions","organizations_url":"https://api.github.com/users/forksaber/orgs","repos_url":"https://api.github.com/users/forksaber/repos","events_url":"https://api.github.com/users/forksaber/events{/privacy}","received_events_url":"https://api.github.com/users/forksaber/received_events","type":"User","site_admin":false},"body":"I think if you don't reenable the signals, they will remain blocked across the exec. So, it is necessary to reenable the signals.\r\n\r\n```markdown\r\n**The new process shall inherit at least the following attributes from the calling process image**:\r\n\r\n[XSI] [Option Start] Nice value (see nice()) [Option End]\r\n\r\n[XSI] [Option Start] semadj values (see semop()) [Option End]\r\n\r\nProcess ID\r\n\r\nParent process ID\r\n\r\nProcess group ID\r\n\r\nSession membership\r\n\r\nReal user ID\r\n\r\nReal group ID\r\n\r\nSupplementary group IDs\r\n\r\nTime left until an alarm clock signal (see alarm())\r\n\r\nCurrent working directory\r\n\r\nRoot directory\r\n\r\nFile mode creation mask (see umask())\r\n\r\n[XSI] [Option Start] File size limit (see ulimit()) [Option End]\r\n\r\n**Process signal mask (see sigprocmask())**\r\n\r\nPending signal (see sigpending())\r\n\r\ntms_utime, tms_stime, tms_cutime, and tms_cstime (see times())\r\n\r\n[XSI] [Option Start] Resource limits [Option End]\r\n\r\n[XSI] [Option Start] Controlling terminal [Option End]\r\n\r\n[XSI] [Option Start] Interval timers [Option End]\r\n\r\nThe initial thread of the new process shall inherit at least the following attributes from the calling thread:\r\n\r\nSignal mask (see sigprocmask() and pthread_sigmask())\r\n\r\nPending signals (see sigpending())\r\n```\r\n\r\nReference:\r\nhttp://pubs.opengroup.org/onlinepubs/009695399/functions/exec.html","created_at":"2018-07-27T09:44:21Z","updated_at":"2018-07-27T09:44:21Z","html_url":"https://github.com/crystal-lang/crystal/pull/6426#discussion_r205721782","pull_request_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/6426","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments/205721782"},"html":{"href":"https://github.com/crystal-lang/crystal/pull/6426#discussion_r205721782"},"pull_request":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/6426"}},"in_reply_to_id":205718395},"pull_request":{"url":"https://api.github.com/repos/crystal-lang/crystal/pulls/6426","id":203056405,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzMDU2NDA1","html_url":"https://github.com/crystal-lang/crystal/pull/6426","diff_url":"https://github.com/crystal-lang/crystal/pull/6426.diff","patch_url":"https://github.com/crystal-lang/crystal/pull/6426.patch","issue_url":"https://api.github.com/repos/crystal-lang/crystal/issues/6426","number":6426,"state":"open","locked":false,"title":"Fix: fork and signal child handlers","user":{"login":"ysbaddaden","id":47380,"node_id":"MDQ6VXNlcjQ3Mzgw","avatar_url":"https://avatars3.githubusercontent.com/u/47380?v=4","gravatar_id":"","url":"https://api.github.com/users/ysbaddaden","html_url":"https://github.com/ysbaddaden","followers_url":"https://api.github.com/users/ysbaddaden/followers","following_url":"https://api.github.com/users/ysbaddaden/following{/other_user}","gists_url":"https://api.github.com/users/ysbaddaden/gists{/gist_id}","starred_url":"https://api.github.com/users/ysbaddaden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ysbaddaden/subscriptions","organizations_url":"https://api.github.com/users/ysbaddaden/orgs","repos_url":"https://api.github.com/users/ysbaddaden/repos","events_url":"https://api.github.com/users/ysbaddaden/events{/privacy}","received_events_url":"https://api.github.com/users/ysbaddaden/received_events","type":"User","site_admin":false},"body":"Fixes an issue where a parent process could receive signals directed to the child or vice-versa.\r\n\r\nfixes #6416 ","created_at":"2018-07-22T13:09:33Z","updated_at":"2018-07-27T09:44:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"680ee9dec22193874208503657ea534e5580d8ed","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":20487867,"node_id":"MDU6TGFiZWwyMDQ4Nzg2Nw==","url":"https://api.github.com/repos/crystal-lang/crystal/labels/kind:bug","name":"kind:bug","color":"fc2929","default":false},{"id":253019694,"node_id":"MDU6TGFiZWwyNTMwMTk2OTQ=","url":"https://api.github.com/repos/crystal-lang/crystal/labels/topic:stdlib","name":"topic:stdlib","color":"fad8c7","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/6426/commits","review_comments_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/6426/comments","review_comment_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/6426/comments","statuses_url":"https://api.github.com/repos/crystal-lang/crystal/statuses/87e6430be9da4006163c4cf72c94ad1f0c474c85","head":{"label":"ysbaddaden:fix-fork-and-signal-child-handlers","ref":"fix-fork-and-signal-child-handlers","sha":"87e6430be9da4006163c4cf72c94ad1f0c474c85","user":{"login":"ysbaddaden","id":47380,"node_id":"MDQ6VXNlcjQ3Mzgw","avatar_url":"https://avatars3.githubusercontent.com/u/47380?v=4","gravatar_id":"","url":"https://api.github.com/users/ysbaddaden","html_url":"https://github.com/ysbaddaden","followers_url":"https://api.github.com/users/ysbaddaden/followers","following_url":"https://api.github.com/users/ysbaddaden/following{/other_user}","gists_url":"https://api.github.com/users/ysbaddaden/gists{/gist_id}","starred_url":"https://api.github.com/users/ysbaddaden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ysbaddaden/subscriptions","organizations_url":"https://api.github.com/users/ysbaddaden/orgs","repos_url":"https://api.github.com/users/ysbaddaden/repos","events_url":"https://api.github.com/users/ysbaddaden/events{/privacy}","received_events_url":"https://api.github.com/users/ysbaddaden/received_events","type":"User","site_admin":false},"repo":{"id":28955723,"node_id":"MDEwOlJlcG9zaXRvcnkyODk1NTcyMw==","name":"crystal","full_name":"ysbaddaden/crystal","owner":{"login":"ysbaddaden","id":47380,"node_id":"MDQ6VXNlcjQ3Mzgw","avatar_url":"https://avatars3.githubusercontent.com/u/47380?v=4","gravatar_id":"","url":"https://api.github.com/users/ysbaddaden","html_url":"https://github.com/ysbaddaden","followers_url":"https://api.github.com/users/ysbaddaden/followers","following_url":"https://api.github.com/users/ysbaddaden/following{/other_user}","gists_url":"https://api.github.com/users/ysbaddaden/gists{/gist_id}","starred_url":"https://api.github.com/users/ysbaddaden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ysbaddaden/subscriptions","organizations_url":"https://api.github.com/users/ysbaddaden/orgs","repos_url":"https://api.github.com/users/ysbaddaden/repos","events_url":"https://api.github.com/users/ysbaddaden/events{/privacy}","received_events_url":"https://api.github.com/users/ysbaddaden/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ysbaddaden/crystal","description":"The Crystal Programming Language","fork":true,"url":"https://api.github.com/repos/ysbaddaden/crystal","forks_url":"https://api.github.com/repos/ysbaddaden/crystal/forks","keys_url":"https://api.github.com/repos/ysbaddaden/crystal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ysbaddaden/crystal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ysbaddaden/crystal/teams","hooks_url":"https://api.github.com/repos/ysbaddaden/crystal/hooks","issue_events_url":"https://api.github.com/repos/ysbaddaden/crystal/issues/events{/number}","events_url":"https://api.github.com/repos/ysbaddaden/crystal/events","assignees_url":"https://api.github.com/repos/ysbaddaden/crystal/assignees{/user}","branches_url":"https://api.github.com/repos/ysbaddaden/crystal/branches{/branch}","tags_url":"https://api.github.com/repos/ysbaddaden/crystal/tags","blobs_url":"https://api.github.com/repos/ysbaddaden/crystal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ysbaddaden/crystal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ysbaddaden/crystal/git/refs{/sha}","trees_url":"https://api.github.com/repos/ysbaddaden/crystal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ysbaddaden/crystal/statuses/{sha}","languages_url":"https://api.github.com/repos/ysbaddaden/crystal/languages","stargazers_url":"https://api.github.com/repos/ysbaddaden/crystal/stargazers","contributors_url":"https://api.github.com/repos/ysbaddaden/crystal/contributors","subscribers_url":"https://api.github.com/repos/ysbaddaden/crystal/subscribers","subscription_url":"https://api.github.com/repos/ysbaddaden/crystal/subscription","commits_url":"https://api.github.com/repos/ysbaddaden/crystal/commits{/sha}","git_commits_url":"https://api.github.com/repos/ysbaddaden/crystal/git/commits{/sha}","comments_url":"https://api.github.com/repos/ysbaddaden/crystal/comments{/number}","issue_comment_url":"https://api.github.com/repos/ysbaddaden/crystal/issues/comments{/number}","contents_url":"https://api.github.com/repos/ysbaddaden/crystal/contents/{+path}","compare_url":"https://api.github.com/repos/ysbaddaden/crystal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ysbaddaden/crystal/merges","archive_url":"https://api.github.com/repos/ysbaddaden/crystal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ysbaddaden/crystal/downloads","issues_url":"https://api.github.com/repos/ysbaddaden/crystal/issues{/number}","pulls_url":"https://api.github.com/repos/ysbaddaden/crystal/pulls{/number}","milestones_url":"https://api.github.com/repos/ysbaddaden/crystal/milestones{/number}","notifications_url":"https://api.github.com/repos/ysbaddaden/crystal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ysbaddaden/crystal/labels{/name}","releases_url":"https://api.github.com/repos/ysbaddaden/crystal/releases{/id}","deployments_url":"https://api.github.com/repos/ysbaddaden/crystal/deployments","created_at":"2015-01-08T08:08:48Z","updated_at":"2018-06-04T19:36:14Z","pushed_at":"2018-07-27T09:28:46Z","git_url":"git://github.com/ysbaddaden/crystal.git","ssh_url":"git@github.com:ysbaddaden/crystal.git","clone_url":"https://github.com/ysbaddaden/crystal.git","svn_url":"https://github.com/ysbaddaden/crystal","homepage":"http://crystal-lang.org","size":41985,"stargazers_count":1,"watchers_count":1,"language":"Crystal","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"crystal-lang:master","ref":"master","sha":"753325a343c71ef1d168dd8c394144d3789f9616","user":{"login":"crystal-lang","id":6539796,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY1Mzk3OTY=","avatar_url":"https://avatars0.githubusercontent.com/u/6539796?v=4","gravatar_id":"","url":"https://api.github.com/users/crystal-lang","html_url":"https://github.com/crystal-lang","followers_url":"https://api.github.com/users/crystal-lang/followers","following_url":"https://api.github.com/users/crystal-lang/following{/other_user}","gists_url":"https://api.github.com/users/crystal-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/crystal-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crystal-lang/subscriptions","organizations_url":"https://api.github.com/users/crystal-lang/orgs","repos_url":"https://api.github.com/users/crystal-lang/repos","events_url":"https://api.github.com/users/crystal-lang/events{/privacy}","received_events_url":"https://api.github.com/users/crystal-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":6887813,"node_id":"MDEwOlJlcG9zaXRvcnk2ODg3ODEz","name":"crystal","full_name":"crystal-lang/crystal","owner":{"login":"crystal-lang","id":6539796,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY1Mzk3OTY=","avatar_url":"https://avatars0.githubusercontent.com/u/6539796?v=4","gravatar_id":"","url":"https://api.github.com/users/crystal-lang","html_url":"https://github.com/crystal-lang","followers_url":"https://api.github.com/users/crystal-lang/followers","following_url":"https://api.github.com/users/crystal-lang/following{/other_user}","gists_url":"https://api.github.com/users/crystal-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/crystal-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crystal-lang/subscriptions","organizations_url":"https://api.github.com/users/crystal-lang/orgs","repos_url":"https://api.github.com/users/crystal-lang/repos","events_url":"https://api.github.com/users/crystal-lang/events{/privacy}","received_events_url":"https://api.github.com/users/crystal-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crystal-lang/crystal","description":"The Crystal Programming Language","fork":false,"url":"https://api.github.com/repos/crystal-lang/crystal","forks_url":"https://api.github.com/repos/crystal-lang/crystal/forks","keys_url":"https://api.github.com/repos/crystal-lang/crystal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crystal-lang/crystal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crystal-lang/crystal/teams","hooks_url":"https://api.github.com/repos/crystal-lang/crystal/hooks","issue_events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/events{/number}","events_url":"https://api.github.com/repos/crystal-lang/crystal/events","assignees_url":"https://api.github.com/repos/crystal-lang/crystal/assignees{/user}","branches_url":"https://api.github.com/repos/crystal-lang/crystal/branches{/branch}","tags_url":"https://api.github.com/repos/crystal-lang/crystal/tags","blobs_url":"https://api.github.com/repos/crystal-lang/crystal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crystal-lang/crystal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crystal-lang/crystal/git/refs{/sha}","trees_url":"https://api.github.com/repos/crystal-lang/crystal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crystal-lang/crystal/statuses/{sha}","languages_url":"https://api.github.com/repos/crystal-lang/crystal/languages","stargazers_url":"https://api.github.com/repos/crystal-lang/crystal/stargazers","contributors_url":"https://api.github.com/repos/crystal-lang/crystal/contributors","subscribers_url":"https://api.github.com/repos/crystal-lang/crystal/subscribers","subscription_url":"https://api.github.com/repos/crystal-lang/crystal/subscription","commits_url":"https://api.github.com/repos/crystal-lang/crystal/commits{/sha}","git_commits_url":"https://api.github.com/repos/crystal-lang/crystal/git/commits{/sha}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/comments{/number}","issue_comment_url":"https://api.github.com/repos/crystal-lang/crystal/issues/comments{/number}","contents_url":"https://api.github.com/repos/crystal-lang/crystal/contents/{+path}","compare_url":"https://api.github.com/repos/crystal-lang/crystal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crystal-lang/crystal/merges","archive_url":"https://api.github.com/repos/crystal-lang/crystal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crystal-lang/crystal/downloads","issues_url":"https://api.github.com/repos/crystal-lang/crystal/issues{/number}","pulls_url":"https://api.github.com/repos/crystal-lang/crystal/pulls{/number}","milestones_url":"https://api.github.com/repos/crystal-lang/crystal/milestones{/number}","notifications_url":"https://api.github.com/repos/crystal-lang/crystal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crystal-lang/crystal/labels{/name}","releases_url":"https://api.github.com/repos/crystal-lang/crystal/releases{/id}","deployments_url":"https://api.github.com/repos/crystal-lang/crystal/deployments","created_at":"2012-11-27T17:32:32Z","updated_at":"2018-07-27T08:24:36Z","pushed_at":"2018-07-27T09:28:48Z","git_url":"git://github.com/crystal-lang/crystal.git","ssh_url":"git@github.com:crystal-lang/crystal.git","clone_url":"https://github.com/crystal-lang/crystal.git","svn_url":"https://github.com/crystal-lang/crystal","homepage":"https://crystal-lang.org","size":37646,"stargazers_count":11440,"watchers_count":11440,"language":"Crystal","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":901,"mirror_url":null,"archived":false,"open_issues_count":679,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":901,"open_issues":679,"watchers":11440,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/6426"},"html":{"href":"https://github.com/crystal-lang/crystal/pull/6426"},"issue":{"href":"https://api.github.com/repos/crystal-lang/crystal/issues/6426"},"comments":{"href":"https://api.github.com/repos/crystal-lang/crystal/issues/6426/comments"},"review_comments":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/6426/comments"},"review_comment":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/6426/commits"},"statuses":{"href":"https://api.github.com/repos/crystal-lang/crystal/statuses/87e6430be9da4006163c4cf72c94ad1f0c474c85"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"forksaber"}}