From 15bed10a92def9645d81ccb319f285e927dc3327 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 19 Jan 2021 09:34:30 +0000 Subject: [PATCH] lei: write daemon errors to the sock directory 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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 802d2cd9..e4f8bedb 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -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; -- 2.44.0