Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

System Functions (s and S) setgid(2)
NAME
setgid - Sets the group ID of the calling process
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsecsrl
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zsecdll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/ysecdll
SYNOPSIS
#include <sys/types.h> /* Optional except for POSIX.1 */
#include <unistd.h>
int setgid(
gid_t gid);
PARAMETERS
gid Specifies the new group ID.
DESCRIPTION
The setgid() function sets the real group ID, effective group ID, and saved-set-group ID of the
calling process to the value specified by the gid parameter.
If the process does not have appropriate privileges but the gid parameter is equal to the real
group ID or the saved-set-group ID, the setgid() function sets the effective group ID to gid; the
real group ID and saved-set-group ID remain unchanged.
If the calling process has appropriate privileges, the real group ID and saved-set-group ID are set
to gid along with the effective group ID.
The group list of the calling process remains unchanged.
The value of gid must be in the range 0 through 65535.
RETURN VALUES
Upon successful completion, the setgid() function returns the value 0 (zero). Otherwise, the
value -1 is returned and errno is set to indicate the error.
ERRORS
If any of the following conditions occurs, the setgid() function sets errno to the corresponding
value:
[EINVAL] The value of the gid parameter is invalid or out of range.
[EPERM] The process lacks appropriate privileges and the gid parameter does not match
the real group ID or the saved-set-group ID.
RELATED INFORMATION
Functions: exec(2), getgid(2), setuid(2).
STANDARDS CONFORMANCE
The following are HP extensions to the XPG4 Version 2 specification:
A process without appropriate privileges can set the effective group ID if the new
effective group ID matches a group ID in the group list of the process.
527186-023 Hewlett-Packard Company 759