40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/perfectqueue/worker.rb', line 40
def run
@pid = fork do
$0 = "perfectqueue-supervisor:#{@runner}"
@sv.run
exit! 0
end
install_signal_handlers
begin
until @finish_flag.set?
pid, status = Process.waitpid2(@pid, Process::WNOHANG)
break if pid
@finish_flag.wait(1)
end
return if pid
if @detach
wait_time = Time.now + @detach_wait
while (w = wait_time - Time.now) > 0
sleep [0.5, w].min
pid, status = Process.waitpid2(@pid, Process::WNOHANG)
break if pid
end
else
end
rescue Errno::ECHILD
end
end
|