module Sanford

need to define class immediately b/c of circular requires:

Constants

InvalidServiceHandlerError
NotFoundError
ShutdownError
VERSION

Public Class Methods

daemon(no_chdir = false, no_close = false) click to toggle source

Full explanation: www.steve.org.uk/Reference/Unix/faq_2.html#SEC16

# File lib/sanford/process.rb, line 197
def self.daemon(no_chdir = false, no_close = false)
  exit if fork
  ::Process.setsid
  exit if fork
  Dir.chdir '/' unless no_chdir
  if !no_close
    null = File.open('/dev/null', 'w')
    STDIN.reopen null
    STDOUT.reopen null
    STDERR.reopen null
  end
  return 0
end