infamy: sniffer: Wait for the capture to actually start in enter()

This commit is contained in:
Mattias Walström
2026-01-23 13:05:34 +01:00
parent 768d3fc233
commit 0d55ea46e0
+8 -1
View File
@@ -4,6 +4,7 @@ import signal
import subprocess
import tempfile
import time
import infamy.util as util
class Sniffer:
"""Helper class for tcpdump"""
@@ -20,7 +21,13 @@ class Sniffer:
def __enter__(self):
cmd = f"tshark -lni iface -w {self.pcap.name} {self.expr}"
arg = cmd.split(" ")
self.proc = self.netns.popen(arg, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
self.proc = self.netns.popen(arg,
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE,
text=True)
util.until(lambda: " -- Capture started." in self.proc.stderr.readline())
def __exit__(self, _, __, ___):
if not self.proc: