Skip to content
BSD syscall#49

svc · unix #49

getlogin

Returns the login name associated with the controlling terminal session.

Prototype

int getlogin(char *namebuf, u_int namelen);

Returns: int

Arguments

NameTypeDirDescription
namebufchar-
namelenu_int-

Version history

XNU tagmacOS#
xnu-1456.1.26macOS 10.6 Snow Leopard49
xnu-1486.2.1149
xnu-1504.15.349
xnu-1504.3.1249
xnu-1504.7.449
xnu-1504.9.1749
xnu-1504.9.2649
xnu-1504.9.3749

Notes

Backed by a per-session string set via setlogin() at login time. It is independent of the real UID, so it correctly identifies the human user behind a su-elevated shell. Returns NULL with errno set when no controlling terminal is associated, common in daemons.

Related APIs

setlogingetuidgeteuidgetsidgethostuuid