method

daemon

Importance_0
v3.2.8 - Show latest stable - 0 notes - Class: Process
daemon(nochdir = nil, noclose = nil) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activesupport/lib/active_support/core_ext/process/daemon.rb, line 2
  def self.daemon(nochdir = nil, noclose = nil)
    exit if fork                     # Parent exits, child continues.
    Process.setsid                   # Become session leader.
    exit if fork                     # Zap session leader. See [1].

    unless nochdir
      Dir.chdir "/"                  # Release old working directory.
    end

    File.umask 0000                  # Ensure sensible umask. Adjust as needed.

    unless noclose
      STDIN.reopen "/dev/null"       # Free file descriptors and
      STDOUT.reopen "/dev/null", "a" # point them somewhere sensible.
      STDERR.reopen '/dev/null', 'a'
    end

    trap("TERM") { exit }

    return 0
  end
Register or log in to add new notes.