Sha256: ec3919659e7cd5b65b81a02dccee11732fd17ccba44c8685d0a3a046033354a4
Contents?: true
Size: 753 Bytes
Versions: 1
Compression:
Stored size: 753 Bytes
Contents
# frozen_string_literal: true module Polyphony # Process patches module Process class << self def watch(cmd = nil, &block) terminated = nil pid = cmd ? Kernel.spawn(cmd) : Polyphony.fork(&block) Thread.current.backend.waitpid(pid) 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) Thread.current.backend.waitpid(pid) rescue Errno::ESRCH # process doesn't exist end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
polyphony-0.51.0 | lib/polyphony/adapters/process.rb |