Skip to content

Commit

Permalink
utilities/ovs-tcpdump.in: Poll the process status
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
apconole authored and blp committed Jul 2, 2016
1 parent 3123526 commit 52654c4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions utilities/ovs-tcpdump.in
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,15 @@ def main():

pipes = _doexec(*([dump_cmd, '-i', mirror_interface] + tcpdargs))
try:
while True:
print(pipes.stdout.readline())
while pipes.poll() is None:
data = pipes.stdout.readline()
if len(data) == 0:
raise KeyboardInterrupt
print(data)
if select.select([sys.stdin], [], [], 0.0)[0]:
data_in = sys.stdin.read()
pipes.stdin.write(data_in)
raise KeyboardInterrupt
except KeyboardInterrupt:
pipes.terminate()
ovsdb.destroy_mirror('m%s' % interface, ovsdb.port_bridge(interface))
Expand Down

0 comments on commit 52654c4

Please sign in to comment.