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