The documentation for the subprocess module says that it can be used as a
replacement for shell pipelines, and gives an example.

On *nix systems, cpython is set to ignore SIGPIPE, and this setting is
inherited by child processes created by the subprocess module. This is nearly
always not what you want when you're constructing a pipeline.

In practice, I think most programs are not particularly designed (or tested)
to run with SIGPIPE ignored, and I've had trouble caused by this a couple of
times now.

If you know about this, it's easy enough to avoid trouble using something like
this as a preexec_fn for subprocess.Popen:

def permit_sigpipe():
    signal.signal(signal.SIGPIPE, signal.SIG_DFL)

My question is: should subprocess.Popen do this by default? In any case, it
would be good to see this issue mentioned near the pipeline example.

-M-


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to