sseettggiidd() -- System Call (libc)

Set group id and user id
#iinncclluuddee <uunniissttdd.hh>
iinntt sseettggiidd(_i_d) iinntt _i_d;

The  _g_r_o_u_p _i_d_e_n_t_i_f_i_e_r  is the  number that identifies  the user  group that
``owns'' a given file.  The suite of groups is set in file /eettcc/ggrroouupp. When
a file  is executable, the executing process  inherits its group identifier
(and thus,  its group-level  permissions) from the  file where it  lives on
disk.  The group identifier comes in three forms:

rreeaall This is the group identifier of the user who is running the process.

eeffffeeccttiivvee
     This is the group identifier  that determines the access rights of the
     process.   These  rights are  the  same  as those  of  the real  group
     identifier unless  they have  been altered  by executing a  file whose
     sseettggiidd bit is set.

ssaavveedd eeffffeeccttiivvee
     This permits  a process to  step back and  forth between its  real and
     effective group  identifiers.  If you  return from an  effective group
     identifier to  your real one, the previously effective  id is saved so
     you can revert to it if need be.

The  system call  sseettggiidd()  lets you  alter  the real  and effective  group
identifiers  of  the  calling process  to  the  group  identifier _g_i_d.  The
behavior of sseettggiidd() varies depending upon the following:

11. If the  effective group  identifier is  that of the  superuser, sseettggiidd()
   sets the real, effective, and saved effective group identifiers to _g_i_d.

22. If  the real  group identifier  is the  same as  _g_i_d, sseettggiidd()  sets the
   effective group identifier to _g_i_d.

33. If the  saved effective group  identifier is same as  _g_i_d, sseettggiidd() sets
   the effective group identifier to _g_i_d.

_S_e_e _A_l_s_o
eexxeeccuuttiioonn, ggeettuuiidd(), lliibbcc, llooggiinn, sseettuuiidd(), uunniissttdd.hh
POSIX Standard, section 4.2.2

_D_i_a_g_n_o_s_t_i_c_s
sseettggiidd() returns zero on success, or -1 on failure.
