1TCGETPGRP(3)               Linux Programmer's Manual              TCGETPGRP(3)
2
3
4

NAME

6       tcgetpgrp, tcsetpgrp - get and set terminal foreground process group
7

SYNOPSIS

9       #include <unistd.h>
10
11       pid_t tcgetpgrp(int fd);
12       int tcsetpgrp(int fd, pid_t pgrp);
13

DESCRIPTION

15       The function tcgetpgrp() returns the process group ID of the foreground
16       process group on the terminal associated to fd, which must be the  con‐
17       trolling terminal of the calling process.
18
19       The  function tcsetpgrp() makes the process group with process group ID
20       pgrp the foreground process group on the  terminal  associated  to  fd,
21       which  must  be  the  controlling  terminal of the calling process, and
22       still be associated  with  its  session.   Moreover,  pgrp  must  be  a
23       (nonempty)  process  group belonging to the same session as the calling
24       process.
25
26       If tcsetpgrp() is called by a member of a background process  group  in
27       its  session, and the calling process is not blocking or ignoring SIGT‐
28       TOU, a SIGTTOU signal is sent to all members of this background process
29       group.
30

RETURN VALUE

32       When  fd refers to the controlling terminal of the calling process, the
33       function tcgetpgrp() will return the foreground  process  group  ID  of
34       that terminal if there is one, and some value larger than 1 that is not
35       presently a process group ID otherwise.  When fd does not refer to  the
36       controlling  terminal of the calling process, -1 is returned, and errno
37       is set to indicate the error.
38
39       When successful, tcsetpgrp() returns 0.  Otherwise, it returns -1,  and
40       errno is set to indicate the error.
41

ERRORS

43       EBADF  fd is not a valid file descriptor.
44
45       EINVAL pgrp has an unsupported value.
46
47       ENOTTY The  calling process does not have a controlling terminal, or it
48              has one but it is not described by fd, or, for tcsetpgrp(), this
49              controlling terminal is no longer associated with the session of
50              the calling process.
51
52       EPERM  pgrp has a supported value, but is not the process group ID of a
53              process in the same session as the calling process.
54

ATTRIBUTES

56       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
57       tributes(7).
58
59       ┌────────────────────────────────────────────┬───────────────┬─────────┐
60Interface                                   Attribute     Value   
61       ├────────────────────────────────────────────┼───────────────┼─────────┤
62tcgetpgrp(), tcsetpgrp()                    │ Thread safety │ MT-Safe │
63       └────────────────────────────────────────────┴───────────────┴─────────┘
64

CONFORMING TO

66       POSIX.1-2001, POSIX.1-2008.
67

NOTES

69       These functions are implemented via the TIOCGPGRP and TIOCSPGRP ioctls.
70
71   History
72       The ioctls appeared in 4.2BSD.  The functions are POSIX inventions.
73

SEE ALSO

75       setpgid(2), setsid(2), credentials(7)
76

COLOPHON

78       This page is part of release 5.13 of the Linux  man-pages  project.   A
79       description  of  the project, information about reporting bugs, and the
80       latest    version    of    this    page,    can     be     found     at
81       https://www.kernel.org/doc/man-pages/.
82
83
84
85GNU                               2021-03-22                      TCGETPGRP(3)
Impressum