xterm python subprocess -
if using subprocess execute xterm on linux, in turn executes other process, seems python (2.6.5) never recognize process (xterm) has completed execution.
consider following code:
import subprocess import shlex import time proc = subprocess.popen(shlex.split('xterm -iconic -title "foo_bar" -e sleep 5')) while true: if proc.poll(): print 'process completed' time.sleep(0.1) this loop infinitely until terminate python interpreter. i'm guessing caused oddity xterm, , not direct cause of python subprocess module, maybe there other smart people out there shed light on situation.
note: calling proc.communicate() in fact return when xterm completes, reason poll method not work.
this program doesn't distinguish between proc.poll() returning none (meaning process still running) , proc.poll() returning 0 (meaning process terminated exit value of zero, conventionally indicating successful completion). change line:
if proc.poll(): to this:
if proc.poll() not none: and see if helps.
Comments
Post a Comment