Python subprocess.Popen PIPE and SIGPIPE
While I browsed posts, I ran into this example below on here , It is saying proc1.stdout.close() is needed to be called for appropriate exit of proc1 , generating SIGPIPE . import subprocess proc1 = subprocess.Popen(['ps', 'cax'], stdout=subprocess.PIPE) proc2 = subprocess.Popen(['grep', 'python'], stdin=proc1.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) proc1.stdout.close() # Allow proc1 to receive a SIGPIPE if proc2 exits. out, err = proc2.communicate() print('out: {0}'.format(out)) print('err: {0}'.format(err)) However, I am not clear on that. Please fix my understanding. SIGPIPE