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 9490D20078 for ; Thu, 31 Dec 2020 13:51:57 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 28/36] lei_to_mail: open FIFOs O_WRONLY so we block Date: Thu, 31 Dec 2020 13:51:46 +0000 Message-Id: <20201231135154.6070-29-e@80x24.org> In-Reply-To: <20201231135154.6070-1-e@80x24.org> References: <20201231135154.6070-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Opening a FIFO with O_RDWR always succeeds on Linux, which cause the cat(1) process invoked by t/lei_to_mail.t to get stuck. Furthermore O_APPEND makes no sense on FIFOs and perhaps there's some kernel out there which will reject it. --- lib/PublicInbox/LeiToMail.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm index 5b80eb27..be338006 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -231,10 +231,11 @@ sub _mbox_write_cb ($$$$) { if ($dst eq '/dev/stdout') { $out = $lei->{1}; } else { # TODO: mbox locking (but mairix doesn't...) - if (!$lei->{opt}->{augment} && -f $dst and !unlink($dst)) { + my $mode = -p $dst ? '>' : '+>>'; + if (-f _ && !$lei->{opt}->{augment} and !unlink($dst)) { die "unlink $dst: $!" if $! != ENOENT; } - open $out, '+>>', $dst or die "open $dst: $!"; + open $out, $mode, $dst or die "open $dst: $!"; # Perl does SEEK_END even with O_APPEND :< $seekable = seek($out, 0, SEEK_SET); die "seek $dst: $!\n" if !$seekable && $! != ESPIPE;