It seems to work as expected for me, but I did notice one thing. When I first tried to run the program as root, it failed to create the first file with a permission error. It turns out that tcpdump changes uid/gid internally to the user/group tcpdump. Since that user/group did not have write access to the directory, it failed. Once I created a subdir and gave tcpdump ownership of the subdir (chown/chgrp), tcpdump performed as expected.