Skip to content
This repository

Ensure foreman is the process group leader #302

Merged
merged 1 commit into from over 1 year ago

3 participants

Christos Trochalakis David Dollar
Christos Trochalakis

Foreman should be the process leader before killing processes using
his process group id.

Before that foreman was broken when it was not spawned from a shell.

(Tested on linux only)

Christos Trochalakis Ensure foreman is the process group leader
Foreman should be the process leader before killing processes using
his process group id.

Before that foreman was broken when it was not spawned from a shell.
44726e3
Christos Trochalakis

Travis reports that the build failed for ruby 1.9.3-p362 (https://travis-ci.org/ddollar/foreman/jobs/3840442).

I can't reproduce it locally with the same ruby version, perhaps this is a travis problem.

David Dollar ddollar merged commit af57bf3 into from January 14, 2013
David Dollar ddollar closed this January 14, 2013
Jonne Haß MrZYX referenced this pull request in diaspora/diaspora April 15, 2013
Open

Gem updates #3855

0 of 22 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 27, 2012
Christos Trochalakis Ensure foreman is the process group leader
Foreman should be the process leader before killing processes using
his process group id.

Before that foreman was broken when it was not spawned from a shell.
44726e3
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 4 additions and 1 deletion. Show diff stats Hide diff stats

  1. 5  lib/foreman/engine.rb
5  lib/foreman/engine.rb
@@ -37,6 +37,9 @@ def initialize(options={})
37 37
   # Start the processes registered to this +Engine+
38 38
   #
39 39
   def start
  40
+    # Make sure foreman is the process group leader.
  41
+    Process.setpgrp unless Foreman.windows?
  42
+
40 43
     trap("TERM") { puts "SIGTERM received"; terminate_gracefully }
41 44
     trap("INT")  { puts "SIGINT received";  terminate_gracefully }
42 45
     trap("HUP")  { puts "SIGHUP received";  terminate_gracefully } if ::Signal.list.keys.include? 'HUP'
@@ -109,7 +112,7 @@ def killall(signal="SIGTERM")
109 112
       end
110 113
     else
111 114
       begin
112  
-        Process.kill "-#{signal}", Process.pid
  115
+        Process.kill "-#{signal}", Process.getpgrp
113 116
       rescue Errno::ESRCH, Errno::EPERM
114 117
       end
115 118
     end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.