I eventually solved it as follows
I installed sys-proctable gem first
gem install 'sys-proctable'
then used the originally published code for the spawn process and the following to kill it (error handling omitted for brevity)
require 'win32/process' require 'sys/proctable' include Win32 include Sys to_kill = .. // PID of spawned process ProcTable.ps do |proc| to_kill << proc.pid if to_kill.include?(proc.ppid) end Process.kill(9, *to_kill) to_kill.each do |pid| Process.waitpid(pid) rescue nil end
You could change kill 9 to something a little less offensive, of course, but that's the essence of the solution.
Ben
source share