在子模塊的Python 2.7版的文檔,我發現下面的代碼片段:更換殼牌管道
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]
來源:https://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline
我不明白這行:p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits.
這裏P1 .stdout正在關閉。如果p2退出,它如何讓p1接收SIGPIPE?
[可能來自python subprocess module的例子](http://stackoverflow.com/questions/6046779/explain-example-from-python-subprocess-module) –