[issue40821] os.getlogin() not working

Christian Heimes report at bugs.python.org
Wed Dec 16 07:32:22 EST 2020


Christian Heimes <lists at cheimes.de> added the comment:

errno 6 is ENXIO. According to https://www.man7.org/linux/man-pages/man3/getlogin.3.html the error code means "The calling process has no controlling terminal.".

os.getlogin() returns the name of the user logged in on the controlling terminal of the process. Typically processes in user session (tty, X session) have a controlling terminal. Processes spawned by a service manager like init, systemd, or upstart usually do not have a controlling terminal. You have to get the user information by other means. Our documentation for os.getlogin() recommends getpass.getuser().

----------
resolution:  -> not a bug
status: open -> pending

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40821>
_______________________________________


More information about the Python-bugs-list mailing list