]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: write daemon errors to the sock directory
authorEric Wong <e@80x24.org>
Tue, 19 Jan 2021 09:34:30 +0000 (09:34 +0000)
committerEric Wong <e@80x24.org>
Thu, 21 Jan 2021 03:29:10 +0000 (03:29 +0000)
Most everything should be captured by the __WARN__ handlers and
routed to syslog, but it appears Perl may write to stderr in
some emergency cases, as can libc or other libraries.  Just
point it to a small file that's cleared on reboot.

lib/PublicInbox/LEI.pm

index 802d2cd95396871bb18f3f110f4f7a04fc21e44b..e4f8bedb20abd626b7a0f50cb67a8aefa69cff3a 100644 (file)
@@ -830,7 +830,9 @@ sub lazy_start {
        require PublicInbox::Listener;
        require PublicInbox::EOFpipe;
        (-p STDOUT) or die "E: stdout must be a pipe\n";
-       open(STDIN, '+<', '/dev/null') or die "redirect stdin failed: $!";
+       my ($err) = ($path =~ m!\A(.+?/)[^/]+\z!);
+       $err .= 'errors.log';
+       open(STDIN, '+>>', $err) or die "open($err): $!";
        POSIX::setsid() > 0 or die "setsid: $!";
        my $pid = fork // die "fork: $!";
        return if $pid;