win32: popen works, popen3 causes hang

David Bolen db3l at fitlinxx.com
Thu May 30 15:41:04 EDT 2002


eggy at island.net (Alex Eggenberger) writes:

> The result is as expected, the program runs and I use output.read() to
> get stdout.  I need some info from stderr.  So I would like to use
> popen3 like this:
> output = os.popen3('spectrum.exe -file script.tcl')
> 
> This causes spectrum.exe to hang.  I can tell it is hung on
> spectrum.exe because I can see the process persists indefinitely in
> Task Manager.
> 
> Is there a difference in the popen and popen3 operate that could be
> causing this problem.  Everything else except the popen call is
> identical in the two cases.

Well, popen() doesn't provide a stdin to the client process, so if the
client tries to read something from it it'll get EOF (or maybe even an
error, I'm not positive) .  popen3() gives you access to the client's
stdin, so there is a handle there and something for the client to
expect to be able to do I/O to.

My guess is spectrum is trying to do some I/O from stdin in some way
that is making it wait.  You don't show any further code after the
popen#() but if you don't send anything to its stdin that might be an
issue.

How about trying to just close the returned child stdin handle after
doing the popen#() - that should create the same effect as popen()
with respect to the client stdin and still give you access to stderr.

--
-- 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