Skip to content

Instantly share code, notes, and snippets.

@dvliman
Created March 12, 2013 17:58
Show Gist options
  • Save dvliman/5145258 to your computer and use it in GitHub Desktop.
Save dvliman/5145258 to your computer and use it in GitHub Desktop.
daemonize
def daemonize
if RUBY_VERSION < "1.9"
exit if fork
Process.setsid
exit if fork
Dir.chdir "/"
STDIN.reopen "/dev/null"
STDOUT.reopen "/dev/null", "a"
STDERR.reopen "/dev/null", "a"
else
Process.daemon
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment