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
13       int tcsetpgrp(int fd, pid_t pgrp);
14

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

ATTRIBUTES

57       For   an   explanation   of   the  terms  used  in  this  section,  see
58       attributes(7).
59
60       ┌─────────────────────────┬───────────────┬─────────┐
61Interface                Attribute     Value   
62       ├─────────────────────────┼───────────────┼─────────┤
63tcgetpgrp(), tcsetpgrp() │ Thread safety │ MT-Safe │
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.07 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                               2015-08-08                      TCGETPGRP(3)
Impressum