]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
xt/httpd-async-stream: avoid waitpid call
authorEric Wong <e@80x24.org>
Sat, 7 Oct 2023 21:24:02 +0000 (21:24 +0000)
committerEric Wong <e@80x24.org>
Sun, 8 Oct 2023 18:54:34 +0000 (18:54 +0000)
We can just use the non-wantarray form of popen_rd to
save us some extra error checking.

xt/httpd-async-stream.t

index 0658c691c826131a5080acba36ace71858591f86..904f2ae99aa3f46a6ace45edf2c591a8454ac6cf 100644 (file)
@@ -58,7 +58,7 @@ my $do_get_all = sub {
        my ($buf, $nr);
        my $bytes = 0;
        my $t0 = now();
-       my ($rd, $pid) = popen_rd([$curl, @CURL_OPT, $url]);
+       my $rd = popen_rd([$curl, @CURL_OPT, $url]);
        while (1) {
                $nr = sysread($rd, $buf, 65536);
                last if !$nr;
@@ -67,9 +67,7 @@ my $do_get_all = sub {
        }
        my $res = $dig->hexdigest;
        my $elapsed = sprintf('%0.3f', now() - $t0);
-       close $rd or die "close curl failed: $!\n";
-       waitpid($pid, 0) == $pid or die "waitpid failed: $!\n";
-       $? == 0 or die "curl failed: $?\n";
+       close $rd or die "close curl failed: $! \$?=$?\n";
        print STDERR "# $job $$ ($?) $res (${elapsed}s) $bytes bytes\n";
        $res;
 };