From 4b369962d303ac832cbda43fbe40562375a23896 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 19 Apr 2019 14:42:26 +0900 Subject: [PATCH] test: kill all subprocesses on timeout. Fixes #5885. --- Library/Homebrew/test.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Library/Homebrew/test.rb b/Library/Homebrew/test.rb index fbe6fa64e7..92ab9dce30 100644 --- a/Library/Homebrew/test.rb +++ b/Library/Homebrew/test.rb @@ -30,5 +30,12 @@ begin rescue Exception => e # rubocop:disable Lint/RescueException error_pipe.puts e.to_json error_pipe.close + pid = Process.pid.to_s + if which("pgrep") && which("pkill") && system("pgrep", "-qP", pid) + $stderr.puts "Killing child processes..." + system "pkill", "-P", pid + sleep 1 + system "pkill", "-9", "-P", pid + end exit! 1 end