tcgetpgrp - get the foreground process group ID
pid_t tcgetpgrp(int fildes);
The tcgetpgrp() function shall return the value of the process group ID of the foreground process group associated with the terminal.
If there is no foreground process group, tcgetpgrp() shall return a value greater than 1 that does not match the process group ID of any existing process group.
The tcgetpgrp() function is allowed from a process that is a member of a background process group; however, the information may be subsequently changed by a process that is a member of a foreground process group.
Upon successful completion, tcgetpgrp() shall return the value of the process group ID of the foreground process associated with the terminal. Otherwise, -1 shall be returned and errno set to indicate the error.
The tcgetpgrp() function shall fail if:
- The fildes argument is not a valid file descriptor.
- The calling process does not have a controlling terminal, or the file is not the controlling terminal.
setsid() , setpgid() , tcsetpgrp() , the Base Definitions volume of IEEE Std 1003.1-2001, <sys/types.h>, <unistd.h>
First released in Issue 3. Included for alignment with the POSIX.1-1988 standard.
In the SYNOPSIS, the optional include of the <sys/types.h> header is removed.
The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:
The requirement to include <sys/types.h> has been removed. Although <sys/types.h> was required for conforming implementations of previous POSIX specifications, it was not required for UNIX applications.
In the DESCRIPTION, text previously conditional on support for _POSIX_JOB_CONTROL is now mandatory. This is a FIPS requirement.