sub popen_rd {
my ($cmd, $env, $opts) = @_;
- unless (wantarray || defined $vfork_spawn || defined $env) {
- open my $fh, '-|', @$cmd or
- die('open `'.join(' ', @$cmd) . " pipe failed: $!\n");
- return $fh
- }
pipe(my ($r, $w)) or die "pipe: $!\n";
$opts ||= {};
my $blocking = $opts->{Blocking};
$r->blocking($blocking) if defined $blocking;
$opts->{1} = fileno($w);
my $pid = spawn($cmd, $env, $opts);
- close $w;
return ($r, $pid) if wantarray;
my $ret = gensym;
tie *$ret, 'PublicInbox::ProcessPipe', $pid, $r;