Skip to content

Commit 49945a6

Browse files
authored
chore(toys): Stop background processes using gen on_interrupt directive (#1036)
1 parent 825f329 commit 49945a6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

shared/.toys.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ def run
122122
end
123123
end
124124
end
125+
on_interrupt do
126+
protoc_pids = `ps aux`.each_line.filter_map { |line| line.split[1].to_i if line.match?(/protoc-gen-ruby_/) }
127+
puts "Terminating protoc-gen-ruby processes."
128+
protoc_pids.each do |pid|
129+
Process.kill("TERM", pid)
130+
end
131+
end
125132

126133
def run_gem_builder service, output_dir
127134
require "gapic/gem_builder"

0 commit comments

Comments
 (0)