Sha256: 4c3cdcda76d71c936f4e4bd84dc3a992acdc4da938d5e5fd185de2b76b7ae327
Contents?: true
Size: 743 Bytes
Versions: 8
Compression:
Stored size: 743 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
8 entries across 8 versions & 1 rubygems