??? Re: popen2 bug?

David Bolen db3l at fitlinxx.com
Thu Sep 20 01:20:45 CEST 2001

Roman Suzi <rnd at onego.ru> writes:

> I thought "grep" or "cat" aren't that interactive...

When run within a pipe (which is what popen* is doing), both of these
will default to processing their stdin and generating output to
stdout, until they see EOF on stdin.  Thus, both can potentially
deadlock if they fill up stdout and block trying to generate output
while the script blocks waiting to supply more input.

But if you're going to use these in another approach (e.g., just
running grep on a file), then no, there doesn't need to be an
interaction.  In that case you're probably better off just using popen
and not popen2 and discard the child process stdin entirely.

-- David
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \

More information about the Python-list mailing list