This has no effect for the (default) single process case with
no master/worker relationship as that does not support SIGWINCH.

Some process managers such as foreman and daemontools rely on
yahnsnot daemonizing, but we still want to be able to process
SIGWINCH in that case.

stdout and stderr may be redirected to a pipe (for cronolog or
similar process), so those are less likely to be attached to a TTY
than stdin.  This also allows users to process SIGWINCH when running
inside a regular terminal if they redirect stdin to /dev/null.

This follows unicorn commit a6077391bb62d0b13016084b0eea36b987afe8f0
Thanks to Dan Moore for suggesting it on the unicorn list.
---
 lib/yahns/server_mp.rb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/yahns/server_mp.rb b/lib/yahns/server_mp.rb
index 2e9da20..9e6ec60 100644
--- a/lib/yahns/server_mp.rb
+++ b/lib/yahns/server_mp.rb
@@ -103,13 +103,13 @@ module Yahns::ServerMP # :nodoc:
       when :USR2 # exec binary, stay alive in case something went wrong
         reexec
       when :WINCH
-        if @daemon_pipe
+        if $stdin.tty?
+          @logger.info "SIGWINCH ignored because we're not daemonized"
+        else
           state = :WINCH
           @logger.info "gracefully stopping all workers"
           soft_kill_each_worker("QUIT")
           @worker_processes = 0
-        else
-          @logger.info "SIGWINCH ignored because we're not daemonized"
         end
       when :TTIN
         state = :respawn unless state == :QUIT
-- 
EW


Reply via email to