tools/qvm-run: do not use os.set_blocking
It's available only in python >= 3.5, but we do support tools on python 3.4 (Debian jessie).
This commit is contained in:
parent
7d25f1bf2b
commit
430ff342d4
@ -21,12 +21,13 @@
|
|||||||
''' qvm-run tool'''
|
''' qvm-run tool'''
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
|
||||||
|
import fcntl
|
||||||
|
|
||||||
import qubesadmin.tools
|
import qubesadmin.tools
|
||||||
import qubesadmin.exc
|
import qubesadmin.exc
|
||||||
|
|
||||||
@ -111,8 +112,11 @@ parser.add_argument('cmd', metavar='COMMAND',
|
|||||||
|
|
||||||
def copy_stdin(stream):
|
def copy_stdin(stream):
|
||||||
'''Copy stdin to *stream*'''
|
'''Copy stdin to *stream*'''
|
||||||
# multiprocessing.Process have sys.stdin connected to /dev/null
|
# multiprocessing.Process have sys.stdin connected to /dev/null, use fd 0
|
||||||
os.set_blocking(0, True)
|
# directly
|
||||||
|
flags = fcntl.fcntl(0, fcntl.F_GETFL)
|
||||||
|
flags &= ~os.O_NONBLOCK
|
||||||
|
fcntl.fcntl(0, fcntl.F_SETFL, flags)
|
||||||
for data in iter(lambda: os.read(0, 65536), b''):
|
for data in iter(lambda: os.read(0, 65536), b''):
|
||||||
if data is None:
|
if data is None:
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user