I would like to call tcpdump in a subprocess in my code. The arguments to tcpdump are such that it keeps writing to 5 files cyclically, rotating whenever the file size reaches 1 MB. Following is the code:
tcpdump tcp -w test -C 1 -W 5
Now I would like to read each file one by one in a thread as soon as it is written completely (1 MB) in a cycle. However, I have no way of informing the thread that the file is ready to read, as subprocess module doesn't seem to allow anything more than status/output of the process to be returned. tcpdump doesn't show any output either about successfully writing to a file.
How do I go about solving this problem?