

#include <sys/types.h> #include <unistd.h> uid_t getuid(void);
getuid determines the real user ID of the calling process.
getuid returns the real user ID of the calling
process.
Under
unusual conditions (for instance, if OpenEdition is not running)
getuid can fail. In this case, getuid issues an MVS user ABEND 1230
to indicate the error.
getuid
to determine the real user ID of a calling process. The user ID
is then passed to the getpwuid function to obtain a pointer
to the user's passwd structure.
#include <sys/types.h>
#include <pwd.h>
#include <unistd.h>
#include <stdio.h>
.
.
.
struct passwd *p;
uid_t uid;
if ((p = getpwuid(uid = getuid())) == NULL)
perror("getpwuid() error");
else {
printf("getpwuid returned the following name and directory for
your user IDn", (int) uid);
printf("pw_name : %s\n", p->pw_name);
printf("pw_dir : %d\n", p->pw_dir);
}
.
.
.
geteuid, getgid, setuid
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.