To: d...@openvswitch.org If there is a pipe behind ovs-tcpdump(such as ovs-tcpdump -i eth0 | grep "192.168.1.1"), the child process (grep "192.168.1.1") may exit first and close the pipe when received SIGTERM. When farther process(ovs-tcpdump) exit, stdout is flushed into broken pipe, and then received a exception IOError. To avoid such problems, ovs-tcp dump first close stdout before exit.
Signed-off-by: Songtao Zhan <zhan...@chinatelecom.cn> --- utilities/ovs-tcpdump.in | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/utilities/ovs-tcpdump.in b/utilities/ovs-tcpdump.in index a49ec9f94..c8a10c727 100755 --- a/utilities/ovs-tcpdump.in +++ b/utilities/ovs-tcpdump.in @@ -538,6 +538,19 @@ def main(): print(data.decode('utf-8')) raise KeyboardInterrupt except KeyboardInterrupt: + # If there is a pipe behind ovs-tcpdump(such as ovs-tcpdump + # -i eth0 | grep "192.168.1.1"), the pipe is no longer available + # after received ctrl+c + # If we write data to an unavailable pipe, a pipe error will be + # reported, so we turn off stdout to avoid subsequence flushing + # of data into the pipe + try: + sys.stdout.close() + # The shutdown operation brushes stdout into the pipe, so a pipe + # error may be reported + except IOError: + pass + if pipes.poll() is None: pipes.terminate() -- 2.31.1 zhan...@chinatelecom.cn _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev