From cb6d8c71abac83d75d2bc990bdbc84748a1309ea Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 19 Jan 2010 18:09:30 -0800 Subject: initialize signal handlers before writing pid file This prevents trigger-happy init scripts from reading the pid file (and thus sending signals) to a not-fully initialized master process to handle them. This does NOT fix anything if other processes are sending signals prematurely without relying on the presence of the pid file. It's not possible to prevent all cases of this in one process, even in a purely C application, so we won't bother trying. We continue to always defer signal handling to the main loop anyways, and signals sent to the master process will be deferred/ignored until Unicorn::HttpServer#join is run. --- test/test_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/test_helper.rb') diff --git a/test/test_helper.rb b/test/test_helper.rb index 3bdbeb1..5b750ee 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -294,3 +294,8 @@ def chunked_spawn(stdout, *cmd) end while true } end + +def reset_sig_handlers + sigs = %w(CHLD).concat(Unicorn::HttpServer::QUEUE_SIGS) + sigs.each { |sig| trap(sig, "DEFAULT") } +end -- cgit v1.2.3-24-ge0c7