tcgetpgrp Subroutine

Purpose

Gets foreground process group ID.

Library

Standard C Library (libc.a)

Syntax

#include <unistd.h>

pid_t tcgetpgrp ( FileDescriptor)
int FileDescriptor;

Description

The tcgetpgrp subroutine returns the value of the process group ID of the foreground process group associated with the terminal. The function can be called from a background process; however, the foreground process can subsequently change the information.

Parameters

Item Description
FileDescriptor Indicates the open file descriptor for the terminal special file.

Return Values

Upon successful completion, the process group ID of the foreground process is returned. If there is no foreground process group, a value greater than 1 that does not match the process group ID of any existing process group is returned. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.

Error Codes

The tcgetpgrp subroutine is unsuccessful if one of the following is true:

Item Description
EBADF The FileDescriptor argument is not a valid file descriptor.
EINVAL The function is not appropriate for the file associated with the FileDescriptor argument.
ENOTTY The calling process does not have a controlling terminal or the file is not the controlling terminal.