unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (SunOS-4.1.3)
Page:
Section:
Apropos / Subsearch:
optional field

GETPGRP(2V)                                                        GETPGRP(2V)



NAME
       getpgrp, setpgrp - return or set the process group of a process

SYNOPSIS
       int getpgrp(pid)
       int pid;

       int setpgrp(pid, pgrp)
       int pgrp;
       int pid;

SYSTEM V SYNOPSIS
       int getpgrp()

       int setpgrp()

DESCRIPTION
       getpgrp()  returns  the  process group of the process indicated by pid.
       If pid is zero, then the call applies to the calling process.

       Process groups are used for distribution of signals, and  by  terminals
       to  arbitrate  requests  for their input.  Processes that have the same
       process group as the terminal run in the foreground and may  read  from
       the  terminal,  while  others  block with a signal when they attempt to
       read.

       This call is thus used by programs such as  csh(1)  to  create  process
       groups  in implementing job control.  The TIOCGPGRP and TIOCSPGRP calls
       described in termio(4) are used to get/set the  process  group  of  the
       control terminal.

       setpgrp() sets the process group of the specified process, (pid) to the
       process group specified by pgrp.  If pid is zero, then the call applies
       to  the  current  (calling) process.  If pgrp is zero and pid refers to
       the calling process, setpgrp() behaves identically to setsid(2V).

       If the effective user ID of the calling process is not super-user, then
       the process to be affected must have the same effective user ID as that
       of the calling process or be a member of the same session as the  call-
       ing process.

SYSTEM V DESCRIPTION
       getpgrp() returns the process group of the calling process.

       setpgrp() behaves identically to setsid().

RETURN VALUES
       getpgrp()  returns  the  process group of the indicated process on suc-
       cess.  On failure, it returns -1 and sets errno to indicate the error.

       setpgrp() returns:

       0      on success.

       -1     on failure and sets errno to indicate the error.

SYSTEM V RETURN VALUES
       getpgrp() returns the process group of the calling process on success.

ERRORS
       setpgrp() fails, and the process group is not altered when one  of  the
       following occurs:

       EACCES         The  value  of  pid  matches  the  process ID of a child
                      process of the calling process and the child process has
                      successfully executed one of the exec() functions.

       EINVAL         The  value  of pgrp is less than zero or is greater than
                      MAXPID,  the  maximum   process   ID   as   defined   in
                      <&lt;sys/param.h>&gt;.

       EPERM          The process indicated by pid is a session leader.

                      The  value of pid is valid but matches the process ID of
                      a child process of the calling  process  and  the  child
                      process  is  not  in  the  same  session  as the calling
                      process.

                      The value of pgrp does not match the process ID  of  the
                      process  indicated by pid and there is no process with a
                      process group ID that matches the value of pgrp  in  the
                      same session as the calling process.

                      The  requested process has a different effective user ID
                      from that of the calling process and is not a descendent
                      of the calling process.

                      The calling process is already a process group leader

                      The process ID of the calling process equals the process
                      group ID of a different process.

       ESRCH          The value of pid does not match the process  ID  of  the
                      calling  process  or  of  a child process of the calling
                      process.

                      The requested process does not exist.

SEE ALSO
       csh(1),  intro(2),  execve(2V),   fork(2V),   getpid(2V),   getuid(2V),
       kill(2V), setpgid(2V), signal(3V), termio(4)



                                21 January 1990                    GETPGRP(2V)