- push @cmd, '-v' if $verbose;
- for my $o ($lei->curl_opt) {
- $o =~ s/\|[a-z0-9]\b//i; # remove single char short option
- if ($o =~ s/=[is]@\z//) {
- my $ary = $opt->{$o} or next;
- push @cmd, map { ("--$o", $_) } @$ary;
- } elsif ($o =~ s/=[is]\z//) {
- my $val = $opt->{$o} // next;
- push @cmd, "--$o", $val;
- } elsif ($opt->{$o}) {
- push @cmd, "--$o";
- }
+ my ($reap_tail, $reap_curl);
+ my $cerr = File::Temp->new(TEMPLATE => 'curl.err-XXXX', TMPDIR => 1);
+ fcntl($cerr, F_SETFL, O_APPEND|O_RDWR) or warn "set O_APPEND: $!";
+ my $rdr = { 2 => $cerr, pgid => 0 };
+ my $coff = 0;
+ my $sigint_reap = $lei->can('sigint_reap');
+ if ($verbose) {
+ # spawn a process to force line-buffering, otherwise curl
+ # will write 1 character at-a-time and parallel outputs
+ # mmmaaayyy llloookkk llliiikkkeee ttthhhiiisss
+ my $o = { 1 => $lei->{2}, 2 => $lei->{2}, pgid => 0 };
+ my $pid = spawn(['tail', '-f', $cerr->filename], undef, $o);
+ $reap_tail = PublicInbox::OnDestroy->new($sigint_reap, $pid);