|
98 | 98 | [:SIGINT, :SIGTERM].each do |signal|
|
99 | 99 | trap(signal) do
|
100 | 100 | SUBPROCESSES.each do |pid|
|
101 |
| - puts "\nSending #{signal} to process #{pid}" |
102 |
| - begin |
103 |
| - Process.kill(signal, pid) |
104 |
| - rescue Errno::ESRCH |
105 |
| - # Already killed |
106 |
| - end |
| 101 | + Utilities.send_signal(signal, pid) |
107 | 102 | end
|
108 | 103 | # Keep running jt which will wait for the subprocesses termination
|
109 | 104 | end
|
@@ -137,6 +132,17 @@ def jvmci_update_and_version
|
137 | 132 | [update, jvmci]
|
138 | 133 | end
|
139 | 134 |
|
| 135 | + def send_signal(signal, pid) |
| 136 | + STDERR.puts "\nSending #{signal} to process #{pid}" |
| 137 | + begin |
| 138 | + Process.kill(signal, pid) |
| 139 | + rescue Errno::ESRCH |
| 140 | + # Already killed |
| 141 | + nil |
| 142 | + end |
| 143 | + end |
| 144 | + module_function :send_signal |
| 145 | + |
140 | 146 | def which(binary)
|
141 | 147 | ENV["PATH"].split(File::PATH_SEPARATOR).each do |dir|
|
142 | 148 | path = "#{dir}/#{binary}"
|
@@ -259,7 +265,10 @@ def raw_sh_with_timeout(timeout, pid)
|
259 | 265 | yield
|
260 | 266 | end
|
261 | 267 | rescue Timeout::Error
|
262 |
| - Process.kill('TERM', pid) |
| 268 | + if send_signal(:SIGTERM, pid) |
| 269 | + sleep 1 |
| 270 | + send_signal(:SIGKILL, pid) |
| 271 | + end |
263 | 272 | yield # Wait and read the pipe if capture: true
|
264 | 273 | :timeout
|
265 | 274 | end
|
@@ -313,8 +322,6 @@ def raw_sh(*args)
|
313 | 322 | end
|
314 | 323 | end
|
315 | 324 |
|
316 |
| - result = status.success? |
317 |
| - |
318 | 325 | if capture
|
319 | 326 | pipe_r.close
|
320 | 327 | end
|
|
0 commit comments