]> Sergey Matveev's repositories - public-inbox.git/commitdiff
daemon: disable SIGWINCH unless explicitly daemonized
authorEric Wong <e@80x24.org>
Tue, 21 Jun 2016 10:03:10 +0000 (10:03 +0000)
committerEric Wong <e@80x24.org>
Tue, 21 Jun 2016 10:14:46 +0000 (10:14 +0000)
Checking stdin/stdout/stderr is not sufficient as the daemon
without setsid can still be under the control of a terminal.

Unfortunately this means systemd users cannot use SIGWINCH,
either.

lib/PublicInbox/Daemon.pm

index a25dd90fa407e81ac1a430474ee4779d7563c5d5..512bb2083c5c65f84f9627c455780c19b7abc62b 100644 (file)
@@ -376,12 +376,12 @@ sub master_loop {
                                exit if $quit++;
                                kill_workers($s);
                        } elsif ($s eq 'WINCH') {
-                               if (-t STDIN || -t STDOUT || -t STDERR) {
+                               if ($daemonize) {
+                                       $worker_processes = 0;
+                               } else {
                                        warn
-"ignoring SIGWINCH while connected to terminal\n";
+"ignoring SIGWINCH since we are not daemonized\n";
                                        $SIG{WINCH} = 'IGNORE';
-                               } else {
-                                       $worker_processes = 0;
                                }
                        } elsif ($s eq 'HUP') {
                                $worker_processes = $set_workers;