]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: use sleep(1) loop for infinite sleep
authorEric Wong <e@80x24.org>
Wed, 3 Feb 2021 08:11:42 +0000 (22:11 -1000)
committerEric Wong <e@80x24.org>
Thu, 4 Feb 2021 01:37:09 +0000 (01:37 +0000)
Perl may internally race and miss signals due to a lack of
self-pipe / eventfd / signalfd / EVFILT_SIGNAL usage.  While our
event loop paths avoid these problems by using signalfd or
EVFILT_SIGNAL, thse sleep() calls are not within the event loop.

lib/PublicInbox/LEI.pm
script/lei

index 005f6f7a33c15af50add827b3074ad430de911d1..28dce0c56c603fee482f873fe7b8d36fde23dba1 100644 (file)
@@ -299,7 +299,7 @@ sub x_it ($$) {
                if (my $signum = ($code & 127)) { # usually SIGPIPE (13)
                        $SIG{PIPE} = 'DEFAULT'; # $SIG{$signum} doesn't work
                        kill $signum, $$;
-                       sleep; # wait for signal
+                       sleep(1) while 1; # wait for signal
                } else {
                        $quit->($code >> 8);
                }
index 58f0dbe92f90b36d243cfd46e1dc21a9aa31e96f..40c21ad882d0e11124a2e3dfacc4181b5a20bdbf 100755 (executable)
@@ -116,7 +116,7 @@ Falling back to (slow) one-shot mode
        sigchld();
        if (my $sig = ($x_it_code & 127)) {
                kill $sig, $$;
-               sleep;
+               sleep(1) while 1;
        }
        exit($x_it_code >> 8);
 } else { # for systems lacking Socket::MsgHdr or Inline::C