2 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use PublicInbox::TestCommon;
7 use POSIX qw(WTERMSIG WIFSIGNALED SIGPIPE);
9 my $f = "$ENV{HOME}/big.eml";
11 for my $out ([], [qw(-f mboxcl2)]) {
12 pipe(my ($r, $w)) or BAIL_OUT $!;
14 if ($^O eq 'linux' && fcntl($w, 1031, 4096)) {
18 open my $fh, '>', $f or xbail "open $f: $!";
19 print $fh <<'EOM' or xbail;
21 Message-ID: <big@example.com>
24 print $fh (' '.('x' x 72)."\n") x (($size / 73) + 1);
26 close $fh or xbail "close: $!";
29 lei_ok(qw(import), $f) if $imported++ == 0;
30 open my $errfh, '>>', "$ENV{HOME}/stderr.log" or xbail $!;
31 my $opt = { run_mode => 0, 2 => $errfh, 1 => $w };
32 my $cmd = [qw(lei q -q -t), @$out, 'z:1..'];
33 my $tp = start_script($cmd, undef, $opt);
35 is(sysread($r, my $buf, 1), 1, 'read one byte');
36 close $r; # trigger SIGPIPE
38 ok(WIFSIGNALED($?), "signaled @$out");
39 is(WTERMSIG($?), SIGPIPE, "got SIGPIPE @$out");