Inquiry regarding the name of subprocess.Popen class

Derek Martin code at pizzashack.org
Tue Sep 2 11:39:09 EDT 2008


On Tue, Sep 02, 2008 at 01:57:26PM +0000, Marc 'BlackJack' Rintsch wrote:
> > I would argue that they don't represent processes at all; the object is
> > a set of files which connect the standard I/O streams of a subprocess to
> > its parent, and methods to operate on those files.
> 
> And the process' ID, an attribute with the process' return code, a method 
> to wait until the process is finished and file objects to communicate 
> with the process.

The name popen is an abbreviation of "pipe open" -- the function, and
the class, open pipes to communicate with another process.  What you
said is correct; however there are numerous other ways to open
subprocesses.  The focus of popen is the communication aspect -- the
opening and control of the pipes -- not the subprocess.  That's the
key difference between popen() and all the other methods of starting a
subprocess.

> > The C library's popen() function, on which this class is based,
> > provides a means to open a file and connect it to the standard steams
> > of a subprocess, making it more closely analogous to what the Popen
> > class does/provides.  As such, "Popen" is a better name to describe
> > this object than "subprocess" would be.
> 
> Is strongly disagree.  The class provides an interface to start and 
> communicate with a `Subprocess`.  Instances stand for processes.

There's more than one way to look at it.  You can disagree all you
like, but your interpretation disagrees with the historical intent of
popen.

> With your reasoning the `file` type should be called `open`.

In this case, the file is a pipe, and the 'p' in popen represents the
pipe.  Unix, by and large, doesn't care that it's a pipe -- file I/O
is intended to work the same way regardless of whether it's a pipe, a
socket, a file on disk, a special device file, or any other file-like
object you can imagine.  That's why I said "file" instead of "pipe" in
my explanation.

Note that in all of these links that talk about popen, the focus is on
opening pipes or file objects, not on subprocesses:

http://www.opengroup.org/onlinepubs/009695399/functions/popen.html
http://docs.python.org/lib/os-newstreams.html
http://us3.php.net/popen
http://docs.hp.com/en/B9106-90010/popen.3S.html
http://www.faqs.org/docs/artu/ch07s02.html

The Linux man page unfortunately copies (verbatim) the FreeBSD man
page, which gets it wrong.  You can not open a process, but you can
definitely open a pipe.

-- 
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20080902/8221f22e/attachment.sig>


More information about the Python-list mailing list