tcgetpgrp()

NAME

tcgetpgrp() - get foreground process group ID

SYNOPSIS

#include <sys/types.h>
#include <unistd.h>

pid_t tcgetpgrp (int fd)

DESCRIPTION

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.

RETURN VALUES

On success, tcgetpgrp(2) returns a process group ID as a pid_t. On failure, it returns -1 and sets errno

ERRORS

tcgetpgrp(2) can fail for the following reasons:

[EBADF]
The fd argument is not a valid file descriptor.
[ENOTTY]
The calling process does not have a controlling terminal or the underlying terminal device represented by fd is not the controlling terminal.

SEE ALSO

setpgid(2)

setsid(2)

tcsetpgrp(2)