Re: 'ps -A' command freezes Popen3



Am Wed, 31 Aug 2005 07:12:49 -0700 schrieb gao_bolin:

> Does anybody know why the following lines would freeze python [2.4.1 on
> Linux]:
>
> import popen2
> a = popen2.Popen3('ps -A')
> a.wait()

Because "ps -A" produces a lot of output to stdout, so that
it blocks. It blocks until you read from the stdout of the subprocess.
If you don't read, it will wait forever. You can redirect the output to a
file "ps -A > /tmp/example". This won't block. Or you use the module
select if you are in a unix environment.

HTH,
Thomas


--
Thomas Güttler, http://www.thomas-guettler.de/


.



Relevant Pages

  • Strange pager (less, more) behavior
    ... the output files to be defaulted to stdout or stderr. ... are to take effect after pending I/O to the terminal has completed. ... Linux kernel) sends it a SIGSTOP signal. ...
    (comp.os.linux.development.apps)
  • Network RiscPC with Linux
    ... Rankin and Theo Markettos for the useful comments. ... how to install it on the Linux partition would be extremely valuable. ... Thomas Rankin: I'll work through your command line suggestions. ...
    (comp.sys.acorn.networking)
  • Re: Satire(?): Todesstrafe oder Schlimmeres fuer Hacker
    ... Thomas Hühn schrieb: ... >> verbirgt oder ein Linux Server eines Content Providers? ... Da sind die Ports ... Next by Date: ...
    (de.soc.recht.datennetze)
  • Re: MIX emulator
    ... I'm running RedHat Linux 7.1. ... io.c:24: initializer element is not constant ... {card_out, stdout}, ... the 3 lines containing the words stdin and stdout. ...
    (comp.os.linux.misc)
  • Re: How do I automatically redirect stdout and stderr when using os.popen2?
    ... popen2 does redirect stdout to a file object. ... connected to the child's stdout, then don't use popen2. ... then dup those file descriptors to stdout/stderr: ...
    (comp.lang.python)