tcgetpgrp(3C)
NAME
tcgetpgrp, tcsetpgrp − Get or set foreground process group ID.
SYNOPSIS
#include <sys/types.h>
pid_t tcgetpgrp (fildes)
int fildes;
int tcsetpgrp (fildes, pgrp_id)
int fildes;
pid_t pgrp_id;
DESCRIPTION
The tcgetpgrp() and tcsetpgrp() functions are defined in the POSIX 1003.1 standard and used in the OCS and BCS standards. CX/UX applications which are not POSIX/OCS/BCS compliant can use these functions.
tcgetpgrp returns the value of the process group ID of the foreground process group associated with the terminal device identified by fildes. A background process may call this function, but the attributes may be changed by a subsequent foreground process call to tcsetpgrp.
Tcsetpgrp sets the foreground process group ID associated with the terminal device identified by fildes. Certain restrictions apply to the use of this function:
1. Fildes must be the controlling terminal of the calling process.
2. This controlling terminal must be currently associated with the session of the calling process.
3. The value of pgrp_id must match a process group ID of a process in the same session as the calling process. Background processes may not call tcsetpgrp. Attempts to do so will result in a SIGTTOU signal being sent to the calling process and all members of its process group. The SIGTTOU signal stops the calling process and all members of its process group unless the calling process is blocking or ignoring this signal.
SEE ALSO
getpgrp(2), setpgrp(2), setpgid(2), setsid(2), termios(7)
DIAGNOSTICS
Upon successful completion, the value of the obtained process group ID is returned by tcgetpgrp and a value of zero is returned by tcsetpgrp. If not, a value of -1 is returned and errno is set.
Errno is set to one of the following values for tcgetpgrp:
[EBADF]
Fildes is not a valid open file descriptor.
[ENOTTY] Fildes is not associated with a terminal device or either the calling process or its session does not have a controlling terminal or the terminal device is not a controlling terminal.
Errno is set to one of the following values for tcsetpgrp:
[EBADF]
Fildes is not a valid open file descriptor.
[EINVAL] The value of pgrp_id is not a valid ID value supported by CX/UX.
[ENOTTY] The calling process does not have a controlling terminal, or fildes is not the controlling terminal of this process, or the controlling terminal is no longer associated with the session of the calling process.
[EPERM] The value of pgrp_id is valid, but does not match the process group ID of a process in the same session as the calling process.
CX/UX Programmer’s Reference Manual