Method: Daemonize.safefork

Defined in:
lib/daemons/daemonize.rb

.safeforkObject

Try to fork if at all possible retrying every 5 sec if the maximum process limit for the system has been reached



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/daemons/daemonize.rb', line 4

def safefork
  tryagain = true

  while tryagain
    tryagain = false
    begin
      if pid = fork
        return pid
      end
    rescue Errno::EWOULDBLOCK
      sleep 5
      tryagain = true
    end
  end
end