I am writing a program in C to analyze packets that are captured by tcpdump. In my program I use popen
to open a pipe to a tcpdump process which captures the packets and dumps the raw data to stdout as shown below.
FILE *tcpdump = popen("tcpdump -s0 -w -", "r");
However, warnings and error messages from tcpdump go straight to stderr, which is displayed in the console. I would like to somehow hide these, so only the output from my program is shown.
One way i tried was to append 2>&1
to the tcpdump command, but then my program would have to differentiate between tcpdump warnings/errors and the raw packet data.
Is there an easy way to silence the stderr output from tcpdump?