character*len getlog, lgnam external getlog lgnam = getlog( )
The getlog function returns the user's login name. If the process is running detached from a terminal, the function returns all blanks.
getlogin(3)