]> Sergey Matveev's repositories - public-inbox.git/commitdiff
daemon: ignore SIGWINCH when connected to terminal
authorEric Wong <e@80x24.org>
Mon, 23 May 2016 01:00:15 +0000 (01:00 +0000)
committerEric Wong <e@80x24.org>
Mon, 23 May 2016 01:01:19 +0000 (01:01 +0000)
Users may change terminal sizes if the process is connected to a
terminal, so we can't reasonably expect SIGWINCH to work as
intended.

lib/PublicInbox/Daemon.pm

index 3d895b0912cc2e7c574b89d2f3a33cb5fedb7663..b64ec87412dc07703d2a171c34ce59fb3511a2e3 100644 (file)
@@ -375,7 +375,13 @@ sub master_loop {
                                exit if $quit++;
                                kill_workers($s);
                        } elsif ($s eq 'WINCH') {
-                               $worker_processes = 0;
+                               if (-t STDIN || -t STDOUT || -t STDERR) {
+                                       warn
+"ignoring SIGWINCH while connected to terminal\n";
+                                       $SIG{WINCH} = 'IGNORE';
+                               } else {
+                                       $worker_processes = 0;
+                               }
                        } elsif ($s eq 'HUP') {
                                $worker_processes = $set_workers;
                                kill_workers($s);