getuid, geteuid, or getuidx Subroutine

Purpose

Gets the real or effective user ID of the current process.

Library

Standard C Library (libc.a)

Syntax

#include <sys/types.h>
#include <unistd.h>
uid_t getuid(void)
uid_t geteuid(void)
#include <id.h>
uid_t getuidx (int type);

Description

The getuid subroutine returns the real user ID of the current process. The geteuid subroutine returns the effective user ID of the current process.

The getuidx subroutine returns the user ID indicated by the type parameter of the calling process.

These subroutines are part of Base Operating System (BOS) Runtime.

Return Values

The getuid, geteuid and getuidx subroutines return the corresponding user ID. The getuid and geteuid subroutines always succeed.

The getuidx subroutine will return -1 and set the global errno variable to EINVAL if the type parameter is not one of ID_REAL, ID_EFFECTIVE, ID_SAVED or ID_LOGIN.

Parameters

Item Description
type Specifies the user ID to get. Must be one of ID_REAL (real user ID), ID_EFFECTIVE (effective user ID), ID_SAVED (saved set-user ID) or ID_LOGIN (login user ID).

Error Codes

If the getuidx subroutine fails the following is returned:

Item Description
EINVAL Indicates the value of the type parameter is invalid.