Skip to content

Commit 8c6450f

Browse files
dylanahsmithhone
authored andcommitted
Unregister signal handlers in child processes.
1 parent 400c6ec commit 8c6450f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/resque/worker.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def work(interval = 5.0, &block)
141141
procline "Forked #{@child} at #{Time.now.to_i}"
142142
Process.wait(@child)
143143
else
144+
unregister_signal_handlers unless @cant_fork
144145
procline "Processing #{job.queue} since #{Time.now.to_i}"
145146
redis.client.reconnect # Don't share connection with parent
146147
perform(job, &block)
@@ -283,6 +284,18 @@ def register_signal_handlers
283284
log! "Registered signals"
284285
end
285286

287+
def unregister_signal_handlers
288+
trap('TERM', 'DEFAULT')
289+
trap('INT', 'DEFAULT')
290+
291+
begin
292+
trap('QUIT', 'DEFAULT')
293+
trap('USR1', 'DEFAULT')
294+
trap('USR2', 'DEFAULT')
295+
rescue ArgumentError
296+
end
297+
end
298+
286299
# Schedule this worker for shutdown. Will finish processing the
287300
# current job.
288301
def shutdown

0 commit comments

Comments
 (0)