From: Gregory P. Smith Date: Sat, 5 Feb 2011 21:49:56 +0000 (+0000) Subject: Merged revisions 88352 via svnmerge from X-Git-Tag: v2.7.2rc1~333 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3e967f2b31c2527dae36a1da7a4ec4f8fb07269;p=python Merged revisions 88352 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r88352 | gregory.p.smith | 2011-02-05 13:47:25 -0800 (Sat, 05 Feb 2011) | 3 lines issue7678 - Properly document how to replace a shell pipeline so that SIGPIPE happens when the end exits before the beginning. ........ --- diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index 03e638e40e..425c526163 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` ^^^^^^^^^^^^^^^^^^^^^^^^^^^