In :mod:`posix`, use ``ttyname_r`` instead of ``ttyname`` for thread safety.