Sha256: e70d1c12a03b579bc1000446d7d1318e966f3027c2b7fcdf1f115d8385cc7830
Contents?: true
Size: 596 Bytes
Versions: 2
Compression:
Stored size: 596 Bytes
Contents
#!/usr/bin/env ruby class Logger attr_accessor :logdev end module Daemon def daemonize(logger = nil) # This causes the grandchild process to be orphaned, # so the init process is responsible for cleaning it up. Kernel.fork and Kernel.exit Process.setsid Kernel.fork and Kernel.exit File.umask 0 Dir.chdir '/' ObjectSpace.each_object(IO) do |io| unless (logger and logger.logdev.dev == io) io.close rescue nil end end STDIN.reopen( '/dev/null') STDOUT.reopen('/dev/null', 'a') STDERR.reopen('/dev/null', 'a') end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
cicloid-backdrop-0.1.0 | lib/daemon.rb |
arldap-0.0.1 | lib/arldap/daemon.rb |