0

I have a python script that does some trickery with the terminal's stdin that I use during devleopment. When I run the script via systemd, however, that same code hangs.

    def init(self):
        print("getting settings")
        self._prev_settings = termios.tcgetattr(self._fd)
        # Never makes it here
        print("prior settings: ", self._prev_settings)

In the above code, self._fd is set to sys.stdin.fileno().

Why is tcgetattr hanging? What's the correct way to fix this?

I would be perfeclty content skipping this initialization if I had an easy way to know that I was running as a daemon or otherwise didn't have a proper stdin setup, but I don't know what signal to check for.

dave mankoff
  • 16,655
  • 6
  • 49
  • 61
  • maybe this: [python - How do I detect whether sys.stdout is attached to terminal or not? - Stack Overflow](https://stackoverflow.com/questions/1077113/how-do-i-detect-whether-sys-stdout-is-attached-to-terminal-or-not) – furas Mar 04 '22 at 04:21

0 Answers0