All pastes #748646 Raw Edit

Anonymous

public text v1 · immutable
#748646 ·published 2007-10-25 00:03 UTC
rendered paste body
import subprocess
import fcntl
import select
import os

fproc = subprocess.Popen(["/usr/games/frotz", "ZORK1.DAT"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
fl = fcntl.fcntl(fproc.stdin, fcntl.F_GETFL)
fl = fl | os.O_NONBLOCK
fcntl.fcntl(fproc.stdin, fcntl.F_SETFL, fl)
fl = fcntl.fcntl(fproc.stdout, fcntl.F_GETFL)
fl = fl | os.O_NONBLOCK
fcntl.fcntl(fproc.stdout, fcntl.F_SETFL, fl)

while 1 == 1:
    ifd, ofd, efd = select.select([fproc.stdout], [], [])
    if fproc.stdout in ifd:
        for line in fproc.stdout:
            print line