From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 91AA71FA17 for ; Tue, 19 Jan 2021 09:34:35 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/9] lei: write daemon errors to the sock directory Date: Tue, 19 Jan 2021 09:34:30 +0000 Message-Id: <20210119093435.17955-5-e@80x24.org> In-Reply-To: <20210119093435.17955-1-e@80x24.org> References: <20210119093435.17955-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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;