Module: Process
- Defined in:
- lib/puma/daemon_ext.rb
Class Method Summary collapse
Class Method Details
.daemon(nochdir = false, noclose = false) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/puma/daemon_ext.rb', line 2 def self.daemon(nochdir=false, noclose=false) exit if fork # Parent exits, child continues. Process.setsid # Become session leader. exit if fork # Zap session leader. See [1]. Dir.chdir "/" unless nochdir # Release old working directory. if !noclose null = File.open "/dev/null", "w+" STDIN.reopen null STDOUT.reopen null STDERR.reopen null end 0 end |