diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2011-02-05 21:47:25 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2011-02-05 21:47:25 (GMT) |
commit | e09d2f1614e96c98b55692281cf2d2be49e9c881 (patch) | |
tree | f7f22e79d16c8d83b9eb60cc8a77a5bc24d4cf81 /Doc/library/subprocess.rst | |
parent | 738236dbd62aab5f0cf27f9ba0f2de3cb65802d2 (diff) | |
download | cpython-e09d2f1614e96c98b55692281cf2d2be49e9c881.zip cpython-e09d2f1614e96c98b55692281cf2d2be49e9c881.tar.gz cpython-e09d2f1614e96c98b55692281cf2d2be49e9c881.tar.bz2 |
issue7678 - Properly document how to replace a shell pipeline so that SIGPIPE
happens when the end exits before the beginning.
Diffstat (limited to 'Doc/library/subprocess.rst')
-rw-r--r-- | Doc/library/subprocess.rst | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst index e08dc8e..bcd38de 100644 --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -519,8 +519,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` ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |