diff options
author | Aaron Conole <aconole@bytheb.org> | 2016-07-01 16:59:41 -0400 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2016-07-01 21:30:20 -0700 |
commit | 52654c4a1272f3f4e8e88f1c710d3e9e545014ef (patch) | |
tree | cf1417fbd8ffdb4c4ea5324bf60890647907e6c8 /utilities | |
parent | 312352673895035bfa286f8cf7c3627d580fdc2b (diff) | |
download | openvswitch-52654c4a1272f3f4e8e88f1c710d3e9e545014ef.tar.gz |
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>
Diffstat (limited to 'utilities')
-rwxr-xr-x | utilities/ovs-tcpdump.in | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/utilities/ovs-tcpdump.in b/utilities/ovs-tcpdump.in index 577f461bf..b29e691c0 100755 --- a/utilities/ovs-tcpdump.in +++ b/utilities/ovs-tcpdump.in @@ -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)) |