{"action":"created","comment":{"url":"https://api.github.com/repos/Netflix/genie/pulls/comments/57248345","id":57248345,"diff_hunk":"@@ -107,6 +108,12 @@ public void executeTask(\n             command.add(\"-u\");\n             command.add(this.jobExecEnv.getJobRequest().getUser());\n         }\n+\n+        // If the OS is linux use setsid to launch the process so that the entire process tree\n+        // is launched in process group id which is the same as the pid of the parent process\n+        if (SystemUtils.IS_OS_LINUX) {\n+            command.add(\"setsid\");\n+        }","path":"genie-core/src/main/java/com/netflix/genie/core/jobs/workflow/impl/JobKickoffTask.java","position":17,"original_position":17,"commit_id":"32617a4f3b3194727ab555223ff1e6a2cc018de0","original_commit_id":"32617a4f3b3194727ab555223ff1e6a2cc018de0","user":{"login":"tgianos","id":7377597,"avatar_url":"https://avatars.githubusercontent.com/u/7377597?v=3","gravatar_id":"","url":"https://api.github.com/users/tgianos","html_url":"https://github.com/tgianos","followers_url":"https://api.github.com/users/tgianos/followers","following_url":"https://api.github.com/users/tgianos/following{/other_user}","gists_url":"https://api.github.com/users/tgianos/gists{/gist_id}","starred_url":"https://api.github.com/users/tgianos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgianos/subscriptions","organizations_url":"https://api.github.com/users/tgianos/orgs","repos_url":"https://api.github.com/users/tgianos/repos","events_url":"https://api.github.com/users/tgianos/events{/privacy}","received_events_url":"https://api.github.com/users/tgianos/received_events","type":"User","site_admin":false},"body":"If we're going to start having lots of OS level differences I'd say we should create subclasses for LinuxJobKickoffTask, OSXJobKickoffTask, etc... that are created as beans based on what OS it is. That may well be overkill for right now but it's something to keep in mind.","created_at":"2016-03-23T22:28:21Z","updated_at":"2016-03-23T22:28:21Z","html_url":"https://github.com/Netflix/genie/pull/205#discussion_r57248345","pull_request_url":"https://api.github.com/repos/Netflix/genie/pulls/205","_links":{"self":{"href":"https://api.github.com/repos/Netflix/genie/pulls/comments/57248345"},"html":{"href":"https://github.com/Netflix/genie/pull/205#discussion_r57248345"},"pull_request":{"href":"https://api.github.com/repos/Netflix/genie/pulls/205"}}},"pull_request":{"url":"https://api.github.com/repos/Netflix/genie/pulls/205","id":63955811,"html_url":"https://github.com/Netflix/genie/pull/205","diff_url":"https://github.com/Netflix/genie/pull/205.diff","patch_url":"https://github.com/Netflix/genie/pull/205.patch","issue_url":"https://api.github.com/repos/Netflix/genie/issues/205","number":205,"state":"open","locked":false,"title":"Added logic to handle kill signals in the bash script","user":{"login":"amitsharma1981","id":1613174,"avatar_url":"https://avatars.githubusercontent.com/u/1613174?v=3","gravatar_id":"","url":"https://api.github.com/users/amitsharma1981","html_url":"https://github.com/amitsharma1981","followers_url":"https://api.github.com/users/amitsharma1981/followers","following_url":"https://api.github.com/users/amitsharma1981/following{/other_user}","gists_url":"https://api.github.com/users/amitsharma1981/gists{/gist_id}","starred_url":"https://api.github.com/users/amitsharma1981/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amitsharma1981/subscriptions","organizations_url":"https://api.github.com/users/amitsharma1981/orgs","repos_url":"https://api.github.com/users/amitsharma1981/repos","events_url":"https://api.github.com/users/amitsharma1981/events{/privacy}","received_events_url":"https://api.github.com/users/amitsharma1981/received_events","type":"User","site_admin":false},"body":"The run.sh script for each job now has a handle_kill_request method which gets triggered once it traps a SIGTERM (kill or kill -15) signal. This initiates a kill sequence as follows:\r\n\r\n0. Writes the Kill exit code (999) to genie.done file.\r\n1. The base process (run.sh) sends a kill to its children\r\n2. Then it checks every second for the next 30 seconds if the children have been killed\r\n3. If all children are dead it exits.\r\n4. If all children are not dead it sends a kill -9 to all children\r\n\r\nThe behavior of kill is slightly different between Linux and Non-Linux OS.\r\n\r\nFor a linux OS , the system launches the run.sh script using setsid. This results in run.sh, its children and all its grandchildren to launch in the same process group which is the pid of run.sh. Once this is done the kill logic uses the \"-g\" flag to send the kill and kill -9 signals to all at the processes in the process group. This signal is send to run.sh itself in this case. The kill signal is handled by run.sh and ignored, but the kill -9 kills the run.sh as well, which is fine as at this point there is nothing else it can do.\r\n\r\nFor a Non-Linux OS we simply launch the run.sh as a normal process and use its pid to send kill and kill -9 signals to its immediate children only, and hope that they handle the killing of their own children.","created_at":"2016-03-23T21:27:52Z","updated_at":"2016-03-23T22:28:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"673d82ab1e9f88d2ba2eb518c8bc576b0642b739","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Netflix/genie/pulls/205/commits","review_comments_url":"https://api.github.com/repos/Netflix/genie/pulls/205/comments","review_comment_url":"https://api.github.com/repos/Netflix/genie/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Netflix/genie/issues/205/comments","statuses_url":"https://api.github.com/repos/Netflix/genie/statuses/32617a4f3b3194727ab555223ff1e6a2cc018de0","head":{"label":"amitsharma1981:develop","ref":"develop","sha":"32617a4f3b3194727ab555223ff1e6a2cc018de0","user":{"login":"amitsharma1981","id":1613174,"avatar_url":"https://avatars.githubusercontent.com/u/1613174?v=3","gravatar_id":"","url":"https://api.github.com/users/amitsharma1981","html_url":"https://github.com/amitsharma1981","followers_url":"https://api.github.com/users/amitsharma1981/followers","following_url":"https://api.github.com/users/amitsharma1981/following{/other_user}","gists_url":"https://api.github.com/users/amitsharma1981/gists{/gist_id}","starred_url":"https://api.github.com/users/amitsharma1981/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amitsharma1981/subscriptions","organizations_url":"https://api.github.com/users/amitsharma1981/orgs","repos_url":"https://api.github.com/users/amitsharma1981/repos","events_url":"https://api.github.com/users/amitsharma1981/events{/privacy}","received_events_url":"https://api.github.com/users/amitsharma1981/received_events","type":"User","site_admin":false},"repo":{"id":54232505,"name":"genie","full_name":"amitsharma1981/genie","owner":{"login":"amitsharma1981","id":1613174,"avatar_url":"https://avatars.githubusercontent.com/u/1613174?v=3","gravatar_id":"","url":"https://api.github.com/users/amitsharma1981","html_url":"https://github.com/amitsharma1981","followers_url":"https://api.github.com/users/amitsharma1981/followers","following_url":"https://api.github.com/users/amitsharma1981/following{/other_user}","gists_url":"https://api.github.com/users/amitsharma1981/gists{/gist_id}","starred_url":"https://api.github.com/users/amitsharma1981/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amitsharma1981/subscriptions","organizations_url":"https://api.github.com/users/amitsharma1981/orgs","repos_url":"https://api.github.com/users/amitsharma1981/repos","events_url":"https://api.github.com/users/amitsharma1981/events{/privacy}","received_events_url":"https://api.github.com/users/amitsharma1981/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/amitsharma1981/genie","description":"Federated Job Execution Engine","fork":true,"url":"https://api.github.com/repos/amitsharma1981/genie","forks_url":"https://api.github.com/repos/amitsharma1981/genie/forks","keys_url":"https://api.github.com/repos/amitsharma1981/genie/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amitsharma1981/genie/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amitsharma1981/genie/teams","hooks_url":"https://api.github.com/repos/amitsharma1981/genie/hooks","issue_events_url":"https://api.github.com/repos/amitsharma1981/genie/issues/events{/number}","events_url":"https://api.github.com/repos/amitsharma1981/genie/events","assignees_url":"https://api.github.com/repos/amitsharma1981/genie/assignees{/user}","branches_url":"https://api.github.com/repos/amitsharma1981/genie/branches{/branch}","tags_url":"https://api.github.com/repos/amitsharma1981/genie/tags","blobs_url":"https://api.github.com/repos/amitsharma1981/genie/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amitsharma1981/genie/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amitsharma1981/genie/git/refs{/sha}","trees_url":"https://api.github.com/repos/amitsharma1981/genie/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amitsharma1981/genie/statuses/{sha}","languages_url":"https://api.github.com/repos/amitsharma1981/genie/languages","stargazers_url":"https://api.github.com/repos/amitsharma1981/genie/stargazers","contributors_url":"https://api.github.com/repos/amitsharma1981/genie/contributors","subscribers_url":"https://api.github.com/repos/amitsharma1981/genie/subscribers","subscription_url":"https://api.github.com/repos/amitsharma1981/genie/subscription","commits_url":"https://api.github.com/repos/amitsharma1981/genie/commits{/sha}","git_commits_url":"https://api.github.com/repos/amitsharma1981/genie/git/commits{/sha}","comments_url":"https://api.github.com/repos/amitsharma1981/genie/comments{/number}","issue_comment_url":"https://api.github.com/repos/amitsharma1981/genie/issues/comments{/number}","contents_url":"https://api.github.com/repos/amitsharma1981/genie/contents/{+path}","compare_url":"https://api.github.com/repos/amitsharma1981/genie/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amitsharma1981/genie/merges","archive_url":"https://api.github.com/repos/amitsharma1981/genie/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amitsharma1981/genie/downloads","issues_url":"https://api.github.com/repos/amitsharma1981/genie/issues{/number}","pulls_url":"https://api.github.com/repos/amitsharma1981/genie/pulls{/number}","milestones_url":"https://api.github.com/repos/amitsharma1981/genie/milestones{/number}","notifications_url":"https://api.github.com/repos/amitsharma1981/genie/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amitsharma1981/genie/labels{/name}","releases_url":"https://api.github.com/repos/amitsharma1981/genie/releases{/id}","deployments_url":"https://api.github.com/repos/amitsharma1981/genie/deployments","created_at":"2016-03-18T21:28:22Z","updated_at":"2016-03-18T21:28:24Z","pushed_at":"2016-03-23T21:18:18Z","git_url":"git://github.com/amitsharma1981/genie.git","ssh_url":"git@github.com:amitsharma1981/genie.git","clone_url":"https://github.com/amitsharma1981/genie.git","svn_url":"https://github.com/amitsharma1981/genie","homepage":"http://netflix.github.io/genie","size":9248,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"develop"}},"base":{"label":"Netflix:develop","ref":"develop","sha":"05268aff224cbe8ba78ea766118a362c3e416074","user":{"login":"Netflix","id":913567,"avatar_url":"https://avatars.githubusercontent.com/u/913567?v=3","gravatar_id":"","url":"https://api.github.com/users/Netflix","html_url":"https://github.com/Netflix","followers_url":"https://api.github.com/users/Netflix/followers","following_url":"https://api.github.com/users/Netflix/following{/other_user}","gists_url":"https://api.github.com/users/Netflix/gists{/gist_id}","starred_url":"https://api.github.com/users/Netflix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Netflix/subscriptions","organizations_url":"https://api.github.com/users/Netflix/orgs","repos_url":"https://api.github.com/users/Netflix/repos","events_url":"https://api.github.com/users/Netflix/events{/privacy}","received_events_url":"https://api.github.com/users/Netflix/received_events","type":"Organization","site_admin":false},"repo":{"id":10828921,"name":"genie","full_name":"Netflix/genie","owner":{"login":"Netflix","id":913567,"avatar_url":"https://avatars.githubusercontent.com/u/913567?v=3","gravatar_id":"","url":"https://api.github.com/users/Netflix","html_url":"https://github.com/Netflix","followers_url":"https://api.github.com/users/Netflix/followers","following_url":"https://api.github.com/users/Netflix/following{/other_user}","gists_url":"https://api.github.com/users/Netflix/gists{/gist_id}","starred_url":"https://api.github.com/users/Netflix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Netflix/subscriptions","organizations_url":"https://api.github.com/users/Netflix/orgs","repos_url":"https://api.github.com/users/Netflix/repos","events_url":"https://api.github.com/users/Netflix/events{/privacy}","received_events_url":"https://api.github.com/users/Netflix/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Netflix/genie","description":"Federated Job Execution Engine","fork":false,"url":"https://api.github.com/repos/Netflix/genie","forks_url":"https://api.github.com/repos/Netflix/genie/forks","keys_url":"https://api.github.com/repos/Netflix/genie/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Netflix/genie/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Netflix/genie/teams","hooks_url":"https://api.github.com/repos/Netflix/genie/hooks","issue_events_url":"https://api.github.com/repos/Netflix/genie/issues/events{/number}","events_url":"https://api.github.com/repos/Netflix/genie/events","assignees_url":"https://api.github.com/repos/Netflix/genie/assignees{/user}","branches_url":"https://api.github.com/repos/Netflix/genie/branches{/branch}","tags_url":"https://api.github.com/repos/Netflix/genie/tags","blobs_url":"https://api.github.com/repos/Netflix/genie/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Netflix/genie/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Netflix/genie/git/refs{/sha}","trees_url":"https://api.github.com/repos/Netflix/genie/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Netflix/genie/statuses/{sha}","languages_url":"https://api.github.com/repos/Netflix/genie/languages","stargazers_url":"https://api.github.com/repos/Netflix/genie/stargazers","contributors_url":"https://api.github.com/repos/Netflix/genie/contributors","subscribers_url":"https://api.github.com/repos/Netflix/genie/subscribers","subscription_url":"https://api.github.com/repos/Netflix/genie/subscription","commits_url":"https://api.github.com/repos/Netflix/genie/commits{/sha}","git_commits_url":"https://api.github.com/repos/Netflix/genie/git/commits{/sha}","comments_url":"https://api.github.com/repos/Netflix/genie/comments{/number}","issue_comment_url":"https://api.github.com/repos/Netflix/genie/issues/comments{/number}","contents_url":"https://api.github.com/repos/Netflix/genie/contents/{+path}","compare_url":"https://api.github.com/repos/Netflix/genie/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Netflix/genie/merges","archive_url":"https://api.github.com/repos/Netflix/genie/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Netflix/genie/downloads","issues_url":"https://api.github.com/repos/Netflix/genie/issues{/number}","pulls_url":"https://api.github.com/repos/Netflix/genie/pulls{/number}","milestones_url":"https://api.github.com/repos/Netflix/genie/milestones{/number}","notifications_url":"https://api.github.com/repos/Netflix/genie/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Netflix/genie/labels{/name}","releases_url":"https://api.github.com/repos/Netflix/genie/releases{/id}","deployments_url":"https://api.github.com/repos/Netflix/genie/deployments","created_at":"2013-06-20T20:35:56Z","updated_at":"2016-03-23T06:59:40Z","pushed_at":"2016-03-23T21:27:52Z","git_url":"git://github.com/Netflix/genie.git","ssh_url":"git@github.com:Netflix/genie.git","clone_url":"https://github.com/Netflix/genie.git","svn_url":"https://github.com/Netflix/genie","homepage":"http://netflix.github.io/genie","size":10577,"stargazers_count":442,"watchers_count":442,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":115,"mirror_url":null,"open_issues_count":23,"forks":115,"open_issues":23,"watchers":442,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Netflix/genie/pulls/205"},"html":{"href":"https://github.com/Netflix/genie/pull/205"},"issue":{"href":"https://api.github.com/repos/Netflix/genie/issues/205"},"comments":{"href":"https://api.github.com/repos/Netflix/genie/issues/205/comments"},"review_comments":{"href":"https://api.github.com/repos/Netflix/genie/pulls/205/comments"},"review_comment":{"href":"https://api.github.com/repos/Netflix/genie/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Netflix/genie/pulls/205/commits"},"statuses":{"href":"https://api.github.com/repos/Netflix/genie/statuses/32617a4f3b3194727ab555223ff1e6a2cc018de0"}}}}