Module: System

Defined in:
lib/dblink/system.rb

Class Method Summary collapse

Class Method Details

.process_alive?(pid, verbose: true) ⇒ Boolean

Returns:

  • (Boolean)

3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/dblink/system.rb', line 3

def self.process_alive?(pid, verbose: true)
  begin
    Process.kill(0, pid)
    return true
  rescue Errno::EPERM                     # changed uid
    puts "No permission to query #{pid}!" if verbose
  rescue Errno::ESRCH
    puts "#{pid} is NOT running." if verbose      # or zombied
  rescue
    puts "Unable to determine status for #{pid} : #{$!}" if verbose
  end
  return false
end

.stop_process(pid) ⇒ Object


17
18
19
20
21
22
23
# File 'lib/dblink/system.rb', line 17

def self.stop_process(pid)
  Process.kill('INT', pid)
  while process_alive?(pid, verbose: CLI_OPTS[:verbose])
    print "."
    sleep 0.3
  end
end