@@ -52,7 +52,8 @@ def start
52
52
else
53
53
# Do not exit but signal the subprocess so we can get their output
54
54
MSpec . subprocesses . each do |pid |
55
- Process . kill :SIGTERM , pid
55
+ kill_wait_one_second :SIGTERM , pid
56
+ hard_kill :SIGKILL , pid
56
57
end
57
58
@fail = true
58
59
@current_state = nil
@@ -89,12 +90,28 @@ def finish
89
90
@thread . join
90
91
end
91
92
93
+ private def hard_kill ( signal , pid )
94
+ begin
95
+ Process . kill signal , pid
96
+ rescue Errno ::ESRCH
97
+ # Process already terminated
98
+ end
99
+ end
100
+
101
+ private def kill_wait_one_second ( signal , pid )
102
+ begin
103
+ Process . kill signal , pid
104
+ sleep 1
105
+ rescue Errno ::ESRCH
106
+ # Process already terminated
107
+ end
108
+ end
109
+
92
110
private def show_backtraces
93
111
java_stacktraces = -> pid {
94
112
if RUBY_ENGINE == 'truffleruby' || RUBY_ENGINE == 'jruby'
95
113
STDERR . puts 'Java stacktraces:'
96
- Process . kill :SIGQUIT , pid
97
- sleep 1
114
+ kill_wait_one_second :SIGQUIT , pid
98
115
end
99
116
}
100
117
@@ -118,8 +135,7 @@ def finish
118
135
119
136
if RUBY_ENGINE == 'truffleruby'
120
137
STDERR . puts "\n Ruby backtraces:"
121
- Process . kill :SIGALRM , pid
122
- sleep 1
138
+ kill_wait_one_second :SIGALRM , pid
123
139
else
124
140
STDERR . puts "Don't know how to print backtraces of a subprocess on #{ RUBY_ENGINE } "
125
141
end
0 commit comments