tcgetpgrp() - get foreground process group ID
#include <sys/types.h>
#include <unistd.h>
pid_t tcgetpgrp (int fd)
This call returns the ID number of the terminal's foreground process group.
A member of a background process group can call this routine, but the value of the process group ID may be later changed by a foreground process.
If there is no foreground process group, tcgetpgrp(2) returns an invalid number.
On success, tcgetpgrp(2) returns a process group ID as a pid_t. On failure, it returns -1 and sets errno
tcgetpgrp(2) can fail for the following reasons:
setpgid(2)
setsid(2)
tcsetpgrp(2)