Your Browser is not longer supported
Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...
{{viewport.spaceProperty.prod}}
setgid - set group ID of process
&pagelevel(4)&pagelevel
Syntax | #include <unistd.h> Optional #include <sys/types.h> int setgid(gid_t gid); |
Description | If the process has appropriate privileges, setgid() sets the real group ID, effective group ID, and the saved set-group-ID to gid. If the process does not have appropriate privileges, but gid is equal to the real group ID or the saved set-group-ID, setgid() sets the effective group ID to gid; the real group ID and saved set-group-ID remain unchanged. Any supplementary group IDs of the calling process remain unchanged. |
Return val. | 0 -1 | if successful. if unsuccessful. errno is set to indicate the error. |
Errors | setgid() will fail if:
|
|
| EINVAL
| The value of gid is invalid and is not supported. |
| EPERM
| The process does not have appropriate privileges and gid does not match the real group ID or the saved set-group-ID. |
Notes | At login, the real user ID, effective user ID, and saved set-user-ID of the login process are set to the user ID of the user responsible for creating the process. The real group ID, effective group ID, and saved set-group-ID of the login process are likewise set to the group ID of the user responsible for creating the process. When a process calls exec() to execute a file, the user and/or group IDs associated with the process may change. If the file executed is a 'set-user-ID' file, the effective user ID and saved set-user-ID of the process are set to the user of the file executed. If the file executed is a 'set-group-ID' file, the effective group ID and saved set-group-ID of the process are set to the group of the file executed. If the file executed is not a 'set-user-ID' or 'set-group-ID' file, the effective user ID, saved set-user-ID, effective group ID, and saved set-group-ID are not changed. |
See also | exec , getgid() , setuid() , sys/types.h , unistd.h .
|