Class: Flamingo::Daemon::ChildProcess

Inherits:
Object
  • Object
show all
Includes:
TrapKeeper
Defined in:
lib/flamingo/daemon/child_process.rb

Direct Known Subclasses

DispatcherProcess, WaderProcess, WebServerProcess

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TrapKeeper

trap

Instance Attribute Details

#pidObject

Returns the value of attribute pid.



8
9
10
# File 'lib/flamingo/daemon/child_process.rb', line 8

def pid
  @pid
end

Instance Method Details

#kill(sig) ⇒ Object Also known as: signal



10
11
12
# File 'lib/flamingo/daemon/child_process.rb', line 10

def kill(sig)
  Process.kill(sig,pid)
end

#running?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
23
24
# File 'lib/flamingo/daemon/child_process.rb', line 15

def running?
  # Borrowed from daemons gem
  Process.kill(0, pid)
  return true
rescue Errno::ESRCH
  return false
rescue ::Exception
  # for example on EPERM (process exists but does not belong to us)
  return true
end

#startObject



26
27
28
29
30
31
# File 'lib/flamingo/daemon/child_process.rb', line 26

def start
  self.pid = fork do
    post_fork
    run
  end
end