sseettssiidd() -- System Call (libc)

Set session identifier
#iinncclluuddee <ssyyss/ttyyppeess.hh>
#iinncclluuddee <uunniissttdd.hh>
ppiidd_tt sseettssiidd ();

If the  calling process  is not a  process-group leader, sseettssiidd()  sets its
process-group  and  session  identifiers  to  its process  identifier,  and
releases the its controlling terminal.

If  all   goes  well,  sseettssiidd()  returns   the  calling  process's  session
identifier.  If  the calling process is already  a process-group leader, or
if process-group  identifier of another process equals  that of the calling
process, sseettssiidd() returns -1 and sets eerrrrnnoo to EEPPEERRMM.

_S_e_e _A_l_s_o
lliibbcc, uunniissttdd.hh
POSIX Standard, section 4.3.2

_N_o_t_e_s
If the calling  process is the last member of  a pipeline started by a job-
control  shell, the  shell  may make  the calling  process a  process-group
leader.  The other processes of the pipeline become members of that process
group.  If this happens, the call to sseettssiidd() fails.

For this reason, a process that  calls sseettssiidd() and expects to be part of a
pipeline should  first fork:  the parent should  exit and the  child should
call  sseettssiidd().  This will  ensure  that the  process  works reliably  when
started by both job-control shells and non-job-control shells.
