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:
Marek Marczykowski-Górecki 2017-08-08 23:48:52 +02:00
parent 7d25f1bf2b
commit 430ff342d4
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -21,12 +21,13 @@
''' qvm-run tool'''
import os
import subprocess
import sys
import subprocess
import multiprocessing
import fcntl
import qubesadmin.tools
import qubesadmin.exc
@ -111,8 +112,11 @@ parser.add_argument('cmd', metavar='COMMAND',
def copy_stdin(stream):
'''Copy stdin to *stream*'''
# multiprocessing.Process have sys.stdin connected to /dev/null
os.set_blocking(0, True)
# multiprocessing.Process have sys.stdin connected to /dev/null, use fd 0
# 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''):
if data is None:
break