diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index 03e638e40e4..425c5261637 100644 --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -450,8 +450,11 @@ Replacing shell pipeline ==> p1 = Popen(["dmesg"], stdout=PIPE) p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE) + p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output = p2.communicate()[0] +The p1.stdout.close() call after starting the p2 is important in order for p1 +to receive a SIGPIPE if p2 exits before p1. Replacing :func:`os.system` ^^^^^^^^^^^^^^^^^^^^^^^^^^^