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.11—49
xnu-1504.15.3—49
xnu-1504.3.12—49
xnu-1504.7.4—49
xnu-1504.9.17—49
xnu-1504.9.26—49
xnu-1504.9.37—49

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