tcpgrp(S) 6 January 1993 tcpgrp(S) Name tcgetpgrp, tcsetpgrp - process group id functions Syntax cc . . . -lc #include <sys/types.h> pid_t tcgetpgrp (fildes); int fildes; int tcsetpgrp (fildes, pgrp_id); int fildes; pid_t pgrp_id; Description These routines identify and set the parent process group ID when job con- trol is defined. The tcgetpgrp function returns the value of the process group ID of the foreground process group associated with the terminal. tcgetpgrp is allowed only from a process that is part of a background process group. However, this information can be changed by a process that is part of the foreground process group by means of the tcsetpgrp call. tcsetpgrp sets the foreground process ID group associated with the termi- nal to the value of pgrpid. fildes must be the file associated with the controlling terminal of the calling process. The controlling terminal must also be currently associated with the session of the calling pro- cess. The value of pgrpid must match a process group ID of a process in the same session as the calling process. Any other value of pgrpid causes an error. Return value If successful, tcgetpgrp returns the process ID of the foreground process group associated with the calling terminal. Otherwise, -1 is returned and errno is set to indicate the error. tcsetpgrp returns a value of zero upon success. Otherwise, -1 is returned and errno is set to indicate the error. Errors If any of the following conditions occur, tcgetpgrp returns -1 and sets errno to the corresponding value: [EBADF] The fildes argument is not a valid file descriptor. [ENOSYS] The tcgetpgrp function is not supported. [ENOTTY] The calling process does not have a controlling terminal or the file described in fildes is not the controlling terminal. If any of the following conditions occur, tcsetpgrp returns -1 and sets errno to the corresponding value: [EBADF] The fildes argument is not a valid file descriptor. [EINVAL] The value of pgrpid is not supported. [ENOSYS] The tcsetpgrp function is not supported. [ENOTTY] The calling process does not have a controlling terminal or the file described in fildes is not the controlling terminal. [EPERM] The value of pgrpid is a value supported by the implementa- tion but does not match the process group ID of a process in the same session as the calling process. See also tcflow(S), tcattr(S) Standards conformance tcgetpgrp and tcsetpgrp are conformant with: IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1)and X/Open Portability Guide, Issue 3, 1989.