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
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/core_ext/process/daemon.rb
activesupport-3.2.22.5 lib/active_support/core_ext/process/daemon.rb
activesupport-3.2.22.4 lib/active_support/core_ext/process/daemon.rb
activesupport-3.2.22.3 lib/active_support/core_ext/process/daemon.rb
activesupport-3.2.22.2 lib/active_support/core_ext/process/daemon.rb
activesupport-3.2.22.1 lib/active_support/core_ext/process/daemon.rb
classiccms-0.7.5 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/process/daemon.rb
classiccms-0.7.4 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/process/daemon.rb
classiccms-0.7.3 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/process/daemon.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/core_ext/process/daemon.rb
activesupport-3.2.22 lib/active_support/core_ext/process/daemon.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.12/lib/active_support/core_ext/process/daemon.rb
activesupport-3.2.21 lib/active_support/core_ext/process/daemon.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/process/daemon.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/activesupport-3.2.18/lib/active_support/core_ext/process/daemon.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.18/lib/active_support/core_ext/process/daemon.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/activesupport-3.2.18/lib/active_support/core_ext/process/daemon.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.18/lib/active_support/core_ext/process/daemon.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/process/daemon.rb
activesupport-3.2.20 lib/active_support/core_ext/process/daemon.rb