1tcgetpgrp(3)               Library Functions Manual               tcgetpgrp(3)
2
3
4

NAME

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

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <unistd.h>
13
14       pid_t tcgetpgrp(int fd);
15       int tcsetpgrp(int fd, pid_t pgrp);
16

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

ATTRIBUTES

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

VERSIONS

69       These functions are implemented via the TIOCGPGRP and TIOCSPGRP ioctls.
70

STANDARDS

72       POSIX.1-2008.
73

HISTORY

75       POSIX.1-2001.
76
77       The ioctls appeared in 4.2BSD.  The functions are POSIX inventions.
78

SEE ALSO

80       setpgid(2), setsid(2), credentials(7)
81
82
83
84Linux man-pages 6.05              2023-07-20                      tcgetpgrp(3)
Impressum