This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 241a58e6 Try kill on process group
241a58e6 is described below

commit 241a58e6aa3541e2bee464959eb2438edf679367
Author: Sebb <[email protected]>
AuthorDate: Thu Oct 19 22:07:24 2023 +0100

    Try kill on process group
---
 tools/site-scan.rb | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/site-scan.rb b/tools/site-scan.rb
index 0f2000fb..fcf95289 100755
--- a/tools/site-scan.rb
+++ b/tools/site-scan.rb
@@ -218,9 +218,15 @@ def exec_with_timeout(cmd, timeout)
     puts "WARN: timeout scanning #{cmd[-1]} #{pid}"
     $stderr.puts "WARN:  #{Time.now} timeout scanning #{cmd[-1]} #{pid}"
     stderr = 'Timeout'
-    # try using less drastic kill
-    Process.kill(-2, pid) # INT
-    Process.kill(-15, pid) # TERM
+    begin
+      # try using less drastic kill first (on process group)
+      Process.kill(-2, -pid) # INT
+      $stderr.puts "WARN:  #{Time.now} sent kill -2 #{-pid}"
+      Process.kill(-15, -pid) # TERM
+      $stderr.puts "WARN:  #{Time.now} sent kill -15 #{-pid}"
+    rescue StandardError => e
+      $stderr.puts "WARN:  #{Time.now} exception #{e}"
+    end
     Process.detach(pid)
   ensure
     wout.close unless wout.closed?

Reply via email to