Module: Daemonize

Included in:
Swee::Server
Defined in:
lib/swee/daemonize.rb

Instance Method Summary collapse

Instance Method Details

#safeforkObject



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

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