# File lib/puppet/daemon.rb, line 15
15:     def daemonize
16:         if pid = fork()
17:             Process.detach(pid)
18:             exit(0)
19:         end
20: 
21:         create_pidfile()
22: 
23:         # Get rid of console logging
24:         Puppet::Util::Log.close(:console)
25: 
26:         Process.setsid
27:         Dir.chdir("/")
28:         begin
29:             $stdin.reopen "/dev/null"
30:             $stdout.reopen "/dev/null", "a"
31:             $stderr.reopen $stdout
32:             Puppet::Util::Log.reopen
33:         rescue => detail
34:             File.open("/tmp/daemonout", "w") { |f|
35:                 f.puts "Could not start %s: %s" % [Puppet[:name], detail]
36:             }
37:             Puppet.err "Could not start %s: %s" % [Puppet[:name], detail]
38:             exit(12)
39:         end
40:     end