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.