Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

40. Login Accounting > Retrieving the Login Name: getlogin()

Retrieving the Login Name: getlogin()

The getlogin() function returns the name of the user logged in on the controlling terminal of the calling process. This function uses the information maintained in the utmp file.

#include <unistd.h>

char *getlogin(void);

Note

Returns pointer to username string, or NULL on error

The getlogin() function calls ttyname() (Terminal Identification) to find the name of the terminal associated with the calling process’s standard input. It then searches the utmp file for a record whose ut_line value matches this terminal name. If a matching record is found, then getlogin() returns the ut_user string from that record.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint