]> git.feebdaed.xyz Git - 0xmirror/xdp-tools.git/commitdiff
xdpdump: Flush stdout after finishing output
authorToke Høiland-Jørgensen <toke@redhat.com>
Thu, 18 Sep 2025 10:59:17 +0000 (12:59 +0200)
committerToke Høiland-Jørgensen <toke@toke.dk>
Fri, 19 Sep 2025 14:06:08 +0000 (16:06 +0200)
Make sure to flush the stdout stream when exiting, before outputting the
end-of-run stats. This avoids output being interleaved because the stats
are written to stderr before stdout has finished flushing.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
xdp-dump/xdpdump.c

index b8f1773583edbf1597a71942d477bee7aeaf61c5..91820858833d313fc5b25da64fc06f0e01700f50 100644 (file)
@@ -670,6 +670,7 @@ static bool capture_on_legacy_interface(struct dumpopt *cfg)
        }
        exit_pcap = NULL;
        rc = true;
+       fflush(stdout);
 
        fprintf(stderr, "\n%"PRIu64" packets captured\n", captured_packets);
        if (pcap_stats(pcap, &ps) == 0) {
@@ -1859,6 +1860,7 @@ static bool capture_on_interface(struct dumpopt *cfg)
        perf_buffer__consume(perf_buf);
 #endif
 
+       fflush(stdout);
        fprintf(stderr, "\n%"PRIu64" packets captured\n",
                perf_ctx.captured_packets);
        fprintf(stderr, "%"PRIu64" packets dropped by perf ring\n",