Method: Open4.maim

Defined in:
lib/crazy_ivan/vendor/open4-1.0.1/lib/open4.rb

.maim(pid, opts = {}) ⇒ Object



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# File 'lib/crazy_ivan/vendor/open4-1.0.1/lib/open4.rb', line 361

def maim pid, opts = {}
#--{{{

  getopt = getopts opts
  sigs = getopt[ 'signals', %w(SIGTERM SIGQUIT SIGKILL) ]
  suspend = getopt[ 'suspend', 4 ]
  pid = Integer pid
  existed = false
  sigs.each do |sig|
    begin
      Process.kill sig, pid
      existed = true 
    rescue Errno::ESRCH
      return(existed ? nil : true)
    end
    return true unless alive? pid
    sleep suspend
    return true unless alive? pid
  end
  return(not alive?(pid)) 
#--}}}

end