In daemon/runner.py, the following code doesn't work when using /dev/tty as value for stdin/stdout/stderr:
self.daemon_context.stdin = open(app.stdin_path, 'r')
self.daemon_context.stdout = open(app.stdout_path, 'w+')
self.daemon_context.stderr = open(app.stderr_path, 'w+', buffering=0)
Indeed, to open tty in Python 3, you need to use open() in binary mode with no buffering (see bug ticket).
I use a workaround but it's quite unclean (need surely some code re-factoring):
if app.stdin_path == '/dev/tty':
self.daemon_context.stdin = open(app.stdin_path, 'rb', buffering=0)
else:
self.daemon_context.stdin = open(app.stdin_path, 'r')
if app.stdout_path == '/dev/tty':
self.daemon_context.stdout = open(
app.stdout_path, 'wb+', buffering=0)
else:
self.daemon_context.stdout = open(app.stdout_path, 'w+')
if app.stderr_path == '/dev/tty':
self.daemon_context.stderr = open(
app.stderr_path, 'wb+', buffering=0)
else:
self.daemon_context.stderr = open(
app.stderr_path, 'w+', buffering=0)
In
daemon/runner.py, the following code doesn't work when using/dev/ttyas value for stdin/stdout/stderr:Indeed, to open tty in Python 3, you need to use
open()in binary mode with no buffering (see bug ticket).I use a workaround but it's quite unclean (need surely some code re-factoring):