Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed daemonization for Ruby 1.9 compatibility #90

Merged
merged 1 commit into from

2 participants

@gluemonkey

Ruby 1.9 has a handy Process.daemon method that doesn't seem to cause problems creating the PID file.

@ileitch
Owner

What problems were you having?

@gluemonkey

ruby-1.9.3-p327

Code execution would stop at line 131, so self.write_pid_file would never be reached.

@ileitch ileitch merged commit de06272 into ileitch:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 17, 2012
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 10 deletions.
  1. +11 −10 lib/rapns/daemon.rb
View
21 lib/rapns/daemon.rb
@@ -121,16 +121,17 @@ def self.delete_pid_file
# :nocov:
def self.daemonize
- exit if pid = fork
- Process.setsid
- exit if pid = fork
-
- Dir.chdir '/'
- File.umask 0000
-
- STDIN.reopen '/dev/null'
- STDOUT.reopen '/dev/null', 'a'
- STDERR.reopen STDOUT
+ 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
end
end
Something went wrong with that request. Please try again.