To: d...@openvswitch.org, i.maxim...@ovn.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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/utilities/ovs-tcpdump.in b/utilities/ovs-tcpdump.in index a49ec9f94..270207d01 100755 --- a/utilities/ovs-tcpdump.in +++ b/utilities/ovs-tcpdump.in @@ -538,6 +538,17 @@ 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() + except IOError: + pass + if pipes.poll() is None: pipes.terminate() -- 2.39.1 zhan...@chinatelecom.cn _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev