# File bin/experimental-filter.rb, line 41 def daemon(nochdir, noclose) pid = fork if pid == -1 return -1 elsif pid != nil exit 0 end Process.setsid() Dir.chdir('/') if (nochdir == 0) if noclose == 0 devnull = open("/dev/null", "r+") $stdin.reopen(devnull) $stdout.reopen(devnull) p = IO::pipe pid = fork if pid == -1 $stderr.reopen(devnull) elsif pid == nil p[1].close STDIN.reopen(p[0]) p[0].close else p[0].close $stderr.reopen(p[1]) p[1].close end end return 0 end