With POSIX IDs disabled, setgid is implemented for program
portability and serves no function. It returns 0 (to indicate
success).
With POSIX IDs enabled, setgid sets the group IDs.
Format
#include <types.h>
#include <unistd.h>
int setgid (__gid_t gid); (_DECC_V4_SOURCE)
int setgid (gid_t gid); (not _DECC_V4_SOURCE)
1 – Argument
gid
The value to which you want the group IDs set.
2 – Description
The setgid function can be used with POSIX style identifiers
enabled or disabled.
POSIX style IDs are supported on OpenVMS Version 7.3-2 and
higher.
With POSIX IDs disabled, the setgid function is implemented for
program portability and serves no function. It returns 0 (to
indicate success).
With POSIX style IDs enabled:
o If the process has the IMPERSONATE privilege, the setgid
function sets the real group ID, effective group ID, and the
saved set-group-ID to gid.
o If the process does not have appropriate privileges but gid is
equal to the real group ID or to the saved set-group-ID, then
the setgid function sets the effective group ID to gid. The
real group ID and saved set-group-ID remain unchanged.
o Any supplementary group IDs of the calling process remain
unchanged.
3 – Return Values
0 Successful completion.
-1 Indicates an error. The function sets errno to
one of the following values:
o EINVAL - The value of the gid argument
is invalid and not supported by the
implementation.
o EPERM - The process does not have
appropriate privileges and gid does not
match the real group ID or the saved set-
group-ID.