diff --git a/nat-lab/tests/utils/tcpdump.py b/nat-lab/tests/utils/tcpdump.py index bb0c6f490..d40059ee6 100644 --- a/nat-lab/tests/utils/tcpdump.py +++ b/nat-lab/tests/utils/tcpdump.py @@ -44,9 +44,7 @@ def __init__( self.count = count self.stdout = "" self.stderr = "" - self.kill_id = ( - "DO_NOT_KILL" + secrets.token_hex(8).upper() if session else None, - ) + self.kill_id = "DO_NOT_KILL" + secrets.token_hex(8).upper() if session else None self.output_notifier.notify_output("listening on", self.start_event) @@ -141,9 +139,14 @@ async def run(self) -> AsyncIterator["TcpDump"]: except TimeoutError as e: print("tcpdump timed out, killing it to create a coredump 🗡️") if self.connection.target_os != TargetOS.Windows: - await self.connection.create_process( - ["kill", "-11", str(self.kill_id)] - ).execute() + if self.kill_id: + await self.connection.create_process( + ["kill", "-11", str(self.kill_id)] + ).execute() + else: + await self.connection.create_process( + ["killall", "-11", "tcpdump"] + ).execute() raise TimeoutError from e yield self # Windump takes so long to flush packets to stdout/file