about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiToMail.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-12-31 13:51:46 +0000
committerEric Wong <e@80x24.org>2021-01-01 05:00:39 +0000
commit3dab16e671b344dbfa925ecc640518532a88b16a (patch)
tree061d3462f5026ccc51edc1eff8e15c34799f1162 /lib/PublicInbox/LeiToMail.pm
parentff91a3b8ba82d1d39dfd6b6ba18ba3134133693b (diff)
downloadpublic-inbox-3dab16e671b344dbfa925ecc640518532a88b16a.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/LeiToMail.pm')
-rw-r--r--lib/PublicInbox/LeiToMail.pm5
1 files 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;