version 1 showing authors affecting page license.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
SETPGID |
|
|
2 |
!!!SETPGID |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
RETURN VALUE |
|
|
7 |
ERRORS |
|
|
8 |
CONFORMING TO |
|
|
9 |
NOTES |
|
|
10 |
SEE ALSO |
|
|
11 |
---- |
|
|
12 |
!!NAME |
|
|
13 |
|
|
|
14 |
|
|
|
15 |
setpgid, getpgid, setpgrp, getpgrp - set/get process group |
|
|
16 |
!!SYNOPSIS |
|
|
17 |
|
|
|
18 |
|
|
|
19 |
__#include __ |
|
|
20 |
|
|
|
21 |
|
|
|
22 |
__int setpgid(pid_t__ ''pid''__, pid_t__ |
|
|
23 |
''pgid''__); |
|
|
24 |
pid_t getpgid(pid_t__ ''pid''__); |
|
|
25 |
int setpgrp(void); |
|
|
26 |
pid_t getpgrp(void);__ |
|
|
27 |
!!DESCRIPTION |
|
|
28 |
|
|
|
29 |
|
|
|
30 |
__setpgid__ sets the process group ID of the process |
|
|
31 |
specified by ''pid'' to ''pgid''. If ''pid'' is |
|
|
32 |
zero, the process ID of the current process is used. If |
|
|
33 |
''pgid'' is zero, the process ID of the process specified |
|
|
34 |
by ''pid'' is used. If __setpgid__ is used to move a |
|
|
35 |
process from one process group to another (as is done by |
|
|
36 |
some shells when creating pipelines), both process groups |
|
|
37 |
must be part of the same session. In this case, the |
|
|
38 |
''pgid'' specifies an existing process group to be joined |
|
|
39 |
and the session ID of that group must match the session ID |
|
|
40 |
of the joining process. |
|
|
41 |
|
|
|
42 |
|
|
|
43 |
__getpgid__ returns the process group ID of the process |
|
|
44 |
specified by ''pid''. If ''pid'' is zero, the process |
|
|
45 |
ID of the current process is used. |
|
|
46 |
|
|
|
47 |
|
|
|
48 |
In the Linux DLL 4.4.1 library, __setpgrp__ simply calls |
|
|
49 |
__setpgid(0,0)__. |
|
|
50 |
|
|
|
51 |
|
|
|
52 |
__getpgrp__ is equivalent to __getpgid(0)__. Each |
|
|
53 |
process group is a member of a session and each process is a |
|
|
54 |
member of the session of which its process group is a |
|
|
55 |
member. |
|
|
56 |
|
|
|
57 |
|
|
|
58 |
Process groups are used for distribution of signals, and by |
|
|
59 |
terminals to arbitrate requests for their input: Processes |
|
|
60 |
that have the same process group as the terminal are |
|
|
61 |
foreground and may read, while others will block with a |
|
|
62 |
signal if they attempt to read. These calls are thus used by |
|
|
63 |
programs such as csh(1) to create process groups in |
|
|
64 |
implementing job control. The __TIOCGPGRP__ and |
|
|
65 |
__TIOCSPGRP__ calls described in termios(4) are |
|
|
66 |
used to get/set the process group of the control |
|
|
67 |
terminal. |
|
|
68 |
|
|
|
69 |
|
|
|
70 |
If a session has a controlling terminal, CLOCAL is not set |
|
|
71 |
and a hangup occurs, then the session leader is sent a |
|
|
72 |
SIGHUP. If the session leader exits, the SIGHUP signal will |
|
|
73 |
be sent to each process in the foreground process group of |
|
|
74 |
the controlling terminal. |
|
|
75 |
|
|
|
76 |
|
|
|
77 |
If the exit of the process causes a process group to become |
|
|
78 |
orphaned, and if any member of the newly-orphaned process |
|
|
79 |
group is stopped, then a SIGHUP signal followed by a SIGCONT |
|
|
80 |
signal will be sent to each process in the newly-orphaned |
|
|
81 |
process group. |
|
|
82 |
!!RETURN VALUE |
|
|
83 |
|
|
|
84 |
|
|
|
85 |
On success, __setpgid__ and __setpgrp__ return zero. |
|
|
86 |
On error, -1 is returned, and ''errno'' is set |
|
|
87 |
appropriately. |
|
|
88 |
|
|
|
89 |
|
|
|
90 |
__getpgid__ returns a process group on success. On error, |
|
|
91 |
-1 is returned, and ''errno'' is set |
|
|
92 |
appropriately. |
|
|
93 |
|
|
|
94 |
|
|
|
95 |
__getpgrp__ always returns the current process |
|
|
96 |
group. |
|
|
97 |
!!ERRORS |
|
|
98 |
|
|
|
99 |
|
|
|
100 |
__EINVAL__ |
|
|
101 |
|
|
|
102 |
|
|
|
103 |
''pgid'' is less than 0. |
|
|
104 |
|
|
|
105 |
|
|
|
106 |
__EPERM__ |
|
|
107 |
|
|
|
108 |
|
|
|
109 |
Various permission violations. |
|
|
110 |
|
|
|
111 |
|
|
|
112 |
__ESRCH__ |
|
|
113 |
|
|
|
114 |
|
|
|
115 |
''pid'' does not match any process. |
|
|
116 |
!!CONFORMING TO |
|
|
117 |
|
|
|
118 |
|
|
|
119 |
The functions __setpgid__ and __getpgrp__ conform to |
|
|
120 |
POSIX.1. The function __setpgrp__ is from BSD 4.2. The |
|
|
121 |
function __getpgid__ conforms to SVr4. |
|
|
122 |
!!NOTES |
|
|
123 |
|
|
|
124 |
|
|
|
125 |
POSIX took __setpgid__ from the BSD function |
|
|
126 |
__setpgrp__. Also SysV has a function with the same name, |
|
|
127 |
but it is identical to setsid(2). |
|
|
128 |
!!SEE ALSO |
|
|
129 |
|
|
|
130 |
|
|
|
131 |
getuid(2), setsid(2), tcsetpgrp(3), |
|
|
132 |
termios(4) |
|
|
133 |
---- |