From 3dab16e671b344dbfa925ecc640518532a88b16a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 31 Dec 2020 13:51:46 +0000 Subject: 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. --- lib/PublicInbox/LeiToMail.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/LeiToMail.pm') 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; -- cgit v1.2.3-24-ge0c7