Skip to content

/dev/tty cannot be used #1

Description

@marienfressinaud

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions