Sha256: 3a6d644140b7cac057e8744213e57082dd5d4a81f6a2583db7e7d89f2a278c84

Contents?: true

Size: 721 Bytes

Versions: 325

Compression:

Stored size: 721 Bytes

Contents

module Process
  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 unless respond_to?(:daemon)
end

Version data entries

325 entries across 281 versions & 29 rubygems

Version Path
font-awesome-rails-3.1.1.2 vendor/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/core_ext/process/daemon.rb
font-awesome-rails-3.1.1.2 vendor/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/core_ext/process/daemon.rb
font-awesome-rails-3.1.1.2 vendor/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/core_ext/process/daemon.rb
font-awesome-rails-3.1.1.1 vendor/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/core_ext/process/daemon.rb
font-awesome-rails-3.1.1.1 vendor/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/core_ext/process/daemon.rb
font-awesome-rails-3.1.1.1 vendor/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/core_ext/process/daemon.rb
challah-1.0.0.beta3 vendor/bundle/gems/activesupport-3.2.13/lib/active_support/core_ext/process/daemon.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/core_ext/process/daemon.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/core_ext/process/daemon.rb
fc-webicons-0.0.4 vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/core_ext/process/daemon.rb
challah-1.0.0.beta2 vendor/bundle/gems/activesupport-3.2.13/lib/active_support/core_ext/process/daemon.rb
challah-1.0.0.beta vendor/bundle/gems/activesupport-3.2.13/lib/active_support/core_ext/process/daemon.rb
challah-1.0.0.beta vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/process/daemon.rb
fc-webicons-0.0.3 vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/core_ext/process/daemon.rb
fc-webicons-0.0.2 vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/core_ext/process/daemon.rb
fc-webicons-0.0.1 vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/core_ext/process/daemon.rb
activesupport-3.2.13 lib/active_support/core_ext/process/daemon.rb
activesupport-3.1.12 lib/active_support/core_ext/process/daemon.rb
activesupport-3.2.13.rc2 lib/active_support/core_ext/process/daemon.rb
activesupport-3.2.13.rc1 lib/active_support/core_ext/process/daemon.rb