X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/9b845d6549f426b892d61b5d05adb2823ecaf991..a0bcaa3081b80b312bef04071c56aa58d820fcf2:/tcpdump.c diff --git a/tcpdump.c b/tcpdump.c index 0d6ff783..520d69f7 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -2082,7 +2082,7 @@ main(int argc, char **argv) if (ndo->ndo_vflag > 0 && WFileName && !print) { /* * When capturing to a file, if "--print" wasn't specified, - *"-v" means tcpdump should, every 10 seconds, + *"-v" means tcpdump should, once per second, * "v"erbosely report the number of packets captured. */ #ifdef USE_WIN32_MM_TIMER @@ -2693,6 +2693,18 @@ RETSIGTYPE requestinfo(int signo _U_) } #endif +static void +print_packets_captured (void) +{ + static u_int prev_packets_captured, first = 1; + + if (infodelay == 0 && (first || packets_captured != prev_packets_captured)) { + fprintf(stderr, "Got %u\r", packets_captured); + first = 0; + prev_packets_captured = packets_captured; + } +} + /* * Called once each second in verbose mode while dumping to file */ @@ -2700,14 +2712,12 @@ RETSIGTYPE requestinfo(int signo _U_) void CALLBACK verbose_stats_dump (UINT timer_id _U_, UINT msg _U_, DWORD_PTR arg _U_, DWORD_PTR dw1 _U_, DWORD_PTR dw2 _U_) { - if (infodelay == 0) - fprintf(stderr, "Got %u\r", packets_captured); + print_packets_captured(); } #elif defined(HAVE_ALARM) static void verbose_stats_dump(int sig _U_) { - if (infodelay == 0) - fprintf(stderr, "Got %u\r", packets_captured); + print_packets_captured(); alarm(1); } #endif