python3: Can't have unbuffered non-binary I/O

The console daemon has, thus far, primarily been tested on python2 for
various reasons.

However, when forcing it to python3 by setting
ansible_python_interpreter=/usr/bin/python3, we find that the console
daemon explodes because Python 3 does not allow unbuffered I/O on
non-binary files.

It should be fine to have /dev/null be binary mode, as it is just being
used to do low-level fileno() operations, the file ojbect is discarded
shortly thereafter.

Change-Id: Ib030863c2de17825e29874733fc5a9b023f7a601
This commit is contained in:
Clint Byrum 2018-09-08 21:38:01 -07:00
parent bde27fa4ec
commit 675f10d271
1 changed files with 1 additions and 1 deletions

View File

@ -49,7 +49,7 @@ def daemonize():
sys.stderr.flush()
i = open('/dev/null', 'r')
o = open('/dev/null', 'a+')
e = open('/dev/null', 'a+', 0)
e = open('/dev/null', 'ab+', 0)
os.dup2(i.fileno(), sys.stdin.fileno())
os.dup2(o.fileno(), sys.stdout.fileno())
os.dup2(e.fileno(), sys.stderr.fileno())