From: Eric Wong Date: Thu, 31 Dec 2020 13:51:46 +0000 (+0000) Subject: lei_to_mail: open FIFOs O_WRONLY so we block X-Git-Tag: v1.7.0~1443 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=3dab16e671b344dbfa925ecc640518532a88b16a;p=public-inbox.git lei_to_mail: open FIFOs O_WRONLY so we block 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. --- 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;