Sha256: 7a7e46ea02dacb5de9b69986a0131f6c2dabecb02e75842745bf72daf11fb884
Contents?: true
Size: 790 Bytes
Versions: 3
Compression:
Stored size: 790 Bytes
Contents
# frozen_string_literal: true module Polyphony module Process class << self def watch(cmd = nil, &block) terminated = nil pid = cmd ? Kernel.spawn(cmd) : Polyphony.fork(&block) watcher = Gyro::Child.new(pid) watcher.await terminated = true ensure kill_process(pid) unless terminated || pid.nil? end def kill_process(pid) cancel_after(5) do kill_and_await('TERM', pid) end rescue Polyphony::Cancel kill_and_await(-9, pid) end def kill_and_await(sig, pid) ::Process.kill(sig, pid) Gyro::Child.new(pid).await rescue SystemCallError # ignore puts 'SystemCallError in kill_and_await' end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
polyphony-0.40 | lib/polyphony/adapters/process.rb |
polyphony-0.39 | lib/polyphony/adapters/process.rb |
polyphony-0.38 | lib/polyphony/adapters/process.rb |