Sets foreground process group ID.
Standard C Library (libc.a)
#include <unistd.h>
int tcsetpgrp ( FileDescriptor, ProcessGroupID)
int FileDescriptor;
pid_t ProcessGroupID;
If the process has a controlling terminal, the tcsetpgrp subroutine sets the foreground process group ID associated with the terminal to the value of the ProcessGroupID parameter. The file associated with the FileDescriptor parameter must be the controlling terminal of the calling process, and the controlling terminal must be currently associated with the session of the calling process. The value of the ProcessGroupID parameter must match a process group ID of a process in the same session as the calling process.
Item | Description |
---|---|
FileDescriptor | Specifies an open file descriptor. |
ProcessGroupID | Specifies the process group identifier. |
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.
This function is unsuccessful if one of the following is true:
Item | Description |
---|---|
EBADF | The FileDescriptor parameter is not a valid file descriptor. |
EINVAL | The ProcessGroupID parameter is invalid. |
ENOTTY | The calling process does not have a controlling terminal, or the file is not the controlling terminal, or the controlling terminal is no longer associated with the session of the calling process. |
EPERM | The ProcessGroupID parameter is valid, but does not match the process group ID of a process in the same session as the calling process. |