Skip to content

Commit 52654c4

Browse files
apconoleblp
authored andcommitted
utilities/ovs-tcpdump.in: Poll the process status
Some options (such as -c X), when passed to tcpdump will cause it to halt. When this occurs, ovs-tcpdump will not recognize that such an event has happened, and will spew newlines across the screen running forever. To fix this, ovs-tcpdump can poll and then raise a KeyboardInterrupt event. Now, when the underlying dump-cmd (such as tcpdump, tshark, etc.) actually signals exit, ovs-tcpdump follows the SIGINT path, telling the database to clean up. Exit is signalled by either returning, 'killing', or closing the output descriptor. Signed-off-by: Aaron Conole <aconole@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
1 parent 3123526 commit 52654c4

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

utilities/ovs-tcpdump.in

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,15 @@ def main():
425425

426426
pipes = _doexec(*([dump_cmd, '-i', mirror_interface] + tcpdargs))
427427
try:
428-
while True:
429-
print(pipes.stdout.readline())
428+
while pipes.poll() is None:
429+
data = pipes.stdout.readline()
430+
if len(data) == 0:
431+
raise KeyboardInterrupt
432+
print(data)
430433
if select.select([sys.stdin], [], [], 0.0)[0]:
431434
data_in = sys.stdin.read()
432435
pipes.stdin.write(data_in)
436+
raise KeyboardInterrupt
433437
except KeyboardInterrupt:
434438
pipes.terminate()
435439
ovsdb.destroy_mirror('m%s' % interface, ovsdb.port_bridge(interface))

0 commit comments

Comments
 (0)