lib/assassin.rb in assassin-0.4.2 vs lib/assassin.rb in assassin-1.4.2

- old
+ new

@@ -1,10 +1,10 @@ require 'tmpdir' require 'securerandom' class Assassin - Version = '0.4.2' unless defined?(Version) + Version = '1.4.2' unless defined?(Version) def Assassin.version Version end @@ -44,26 +44,30 @@ [pid, path] end def Assassin.script_for(child_pid, options = {}) parent_pid = Process.pid + delay = (options[:delay] || 0.42).to_f script = <<-__ Process.daemon require 'fileutils' at_exit{ FileUtils.rm_f(__FILE__) } parent_pid = #{ parent_pid } child_pid = #{ child_pid } + delay = #{ delay } m = 24*60*60 n = 42 m.times do begin Process.kill(0, parent_pid) rescue Object => e + sleep(delay) + if e.is_a?(Errno::ESRCH) n.times do begin Process.kill(15, child_pid) rescue nil sleep(rand + rand)