Sha256: 10bb4889aa69f444d22a7fee39ee0f9b80b379d39f16bde3379cfda83da7b367

Contents?: true

Size: 742 Bytes

Versions: 92

Compression:

Stored size: 742 Bytes

Contents

module Kernel
  # Turns the current script into a daemon process that detaches from the console.
  # It can be shut down with a TERM signal.
  def daemonize
    exit if fork                   # Parent exits, child continues.
    Process.setsid                 # Become session leader.
    exit if fork                   # Zap session leader. See [1].
    Dir.chdir "/"                  # Release old working directory.
    File.umask 0000                # Ensure sensible umask. Adjust as needed.
    STDIN.reopen "/dev/null"       # Free file descriptors and
    STDOUT.reopen "/dev/null", "a" # point them somewhere sensible.
    STDERR.reopen STDOUT           # STDOUT/ERR should better go to a logfile.
    trap("TERM") { exit }
  end
end

Version data entries

92 entries across 92 versions & 7 rubygems

Version Path
activesupport-1.4.1 lib/active_support/core_ext/kernel/daemonizing.rb
activesupport-1.4.3 lib/active_support/core_ext/kernel/daemonizing.rb
activesupport-1.4.4 lib/active_support/core_ext/kernel/daemonizing.rb
activesupport-1.3.1 lib/active_support/core_ext/kernel/daemonizing.rb
activesupport-1.3.0 lib/active_support/core_ext/kernel/daemonizing.rb
activesupport-2.0.0 lib/active_support/core_ext/kernel/daemonizing.rb
activesupport-2.0.1 lib/active_support/core_ext/kernel/daemonizing.rb
activesupport-1.4.2 lib/active_support/core_ext/kernel/daemonizing.rb
activesupport-1.4.0 lib/active_support/core_ext/kernel/daemonizing.rb
activesupport-2.0.2 lib/active_support/core_ext/kernel/daemonizing.rb
activesupport-2.0.5 lib/active_support/core_ext/kernel/daemonizing.rb
activesupport-2.0.4 lib/active_support/core_ext/kernel/daemonizing.rb
backlog-0.0.0 vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb
backlog-0.0.1 vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb
backlog-0.0.2 vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb
backlog-0.0.5 vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb
backlog-0.0.4 vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb
backlog-0.1.0 vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb
backlog-0.1.1 vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb
backlog-0.1.2 vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb