tcpdump mailing list archives

Stdout flush patch


From: Michael Welzl <michael.welzl () uibk ac at>
Date: 02 Sep 2003 15:48:55 +0200

Hi all,

tcpdump writes its output with printf and doesn't flush the
stdout buffer - which seems to make no difference in a
bash shell, but led to an output buffering problem (hangs
for a while, then gives you a lot of output at once, then
hangs, etc. ...) as soon as I tried to pipe the output.

This occured to me with RedHat 9 using a 2.4.20-8 kernel,
libpcap-0.7.2 and tcpdump-3.7.2, and it's quite annoying
if, for instance, you want to pipe tcpdump to a perl script
to monitor the bandwidth of a flow. To see if it applies
to your system, try calling "tcpdump | cat".

I got rid of this by calling fflush(stdout) after each call
to a "printer" directly in tcpdump.c. The patch is at
http://www.welzl.at/tools/bandwidth-monitor/index.html

Best regards,
Michael Welzl

-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:tcpdump-workers-request () tcpdump org?body=unsubscribe


Current thread: