Is shutil.get_terminal_size useless?

Chris Angelico rosuav at
Sat Jan 28 15:36:25 EST 2017

On Sun, Jan 29, 2017 at 7:04 AM, eryk sun <eryksun at> wrote:
> Now let's get rid of the terminal via setsid:
>    $ echo spam |
>     > 2>&1 setsid python3 -c 'import os
>     > fd ="/dev/tty", os.O_RDONLY)
>     > print(os.get_terminal_size(fd))' |
>     > cat
>     Traceback (most recent call last):
>       File "<string>", line 2, in <module>
>     OSError: [Errno 6] No such device or address: '/dev/tty'

And you could have achieved the same result in any number of other
ways, too, like setting yourself up with the local boot system (true
of systemd, upstart, sysvinit, and probably of all others too), or
cron, or inetd, etc, etc, etc. You can definitely lose access to your
"controlling terminal".


More information about the Python-list mailing list