diff options
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | chpst.8 | 265 |
2 files changed, 270 insertions, 0 deletions
@@ -6,3 +6,8 @@ | |||
6 | # hasshsgr.h | 6 | # hasshsgr.h |
7 | 7 | ||
8 | chpst: *.c | 8 | chpst: *.c |
9 | |||
10 | .PHONY: man | ||
11 | |||
12 | man: | ||
13 | groff -Tascii -man chpst.8 | less | ||
@@ -0,0 +1,265 @@ | |||
1 | .TH chpst 8 | ||
2 | .SH NAME | ||
3 | chpst \- runs a program with a changed process state | ||
4 | .SH SYNOPSIS | ||
5 | .B chpst | ||
6 | [\-vP012] | ||
7 | [\-u | ||
8 | .IR user ] | ||
9 | [\-U | ||
10 | .IR user ] | ||
11 | [\-b | ||
12 | .IR argv0 ] | ||
13 | [-e | ||
14 | .IR dir ] | ||
15 | [\-/ | ||
16 | .IR root ] | ||
17 | [\-n | ||
18 | .IR inc ] | ||
19 | [-l|-L | ||
20 | .IR lock ] | ||
21 | [-m | ||
22 | .IR bytes ] | ||
23 | [-d | ||
24 | .IR bytes ] | ||
25 | [-o | ||
26 | .IR n ] | ||
27 | [-p | ||
28 | .IR n ] | ||
29 | [-f | ||
30 | .IR bytes ] | ||
31 | [-c | ||
32 | .IR bytes ] | ||
33 | .I prog | ||
34 | .SH DESCRIPTION | ||
35 | .I prog | ||
36 | consists of one or more arguments. | ||
37 | .P | ||
38 | .B chpst | ||
39 | changes the process state according to the given options, and runs | ||
40 | .IR prog . | ||
41 | .SH OPTIONS | ||
42 | .TP | ||
43 | .B \-u \fI[:]user[:group] | ||
44 | setuidgid. | ||
45 | Set uid and gid to the | ||
46 | .IR user 's | ||
47 | uid and gid, as found in | ||
48 | .IR /etc/passwd . | ||
49 | If | ||
50 | .I user | ||
51 | is followed by a colon and a | ||
52 | .IR group , | ||
53 | set the gid to | ||
54 | .IR group 's | ||
55 | gid, as found in | ||
56 | .IR /etc/group , | ||
57 | instead of | ||
58 | .IR user 's | ||
59 | gid. | ||
60 | If | ||
61 | .I group | ||
62 | consists of a colon-separated list of group names, | ||
63 | .B chpst | ||
64 | sets the group ids of all listed groups. | ||
65 | If | ||
66 | .I user | ||
67 | is prefixed with a colon, the | ||
68 | .I user | ||
69 | and all | ||
70 | .I group | ||
71 | arguments are interpreted as uid and gids respectivly, and not looked up in | ||
72 | the password or group file. | ||
73 | All initial supplementary groups are removed. | ||
74 | .TP | ||
75 | .B \-U \fI[:]user[:group] | ||
76 | envuidgid. | ||
77 | Set the environment variables $UID and $GID to the | ||
78 | .IR user 's | ||
79 | uid and gid, as found in | ||
80 | .IR /etc/passwd . | ||
81 | If | ||
82 | .I user | ||
83 | is followed by a colon and a | ||
84 | .IR group , | ||
85 | set $GID to the | ||
86 | .IR group 's | ||
87 | gid, as found in | ||
88 | .IR /etc/group , | ||
89 | instead of | ||
90 | .IR user 's | ||
91 | gid. | ||
92 | If | ||
93 | .I user | ||
94 | is prefixed with a colon, the | ||
95 | .I user | ||
96 | and | ||
97 | .I group | ||
98 | arguments are interpreted as uid and gid respectivly, and not looked up in | ||
99 | the password or group file. | ||
100 | .TP | ||
101 | .B \-b \fIargv0 | ||
102 | argv0. | ||
103 | Run | ||
104 | .I prog | ||
105 | with | ||
106 | .I argv0 | ||
107 | as the 0th argument. | ||
108 | .TP | ||
109 | .B \-e \fIdir | ||
110 | envdir. | ||
111 | Set various environment variables as specified by files in the directory | ||
112 | .IR dir : | ||
113 | If | ||
114 | .I dir | ||
115 | contains a file named | ||
116 | .I k | ||
117 | whose first line is | ||
118 | .IR v , | ||
119 | .B chpst | ||
120 | removes the environment variable | ||
121 | .I k | ||
122 | if it exists, and then adds the environment variable | ||
123 | .I k | ||
124 | with the value | ||
125 | .IR v . | ||
126 | The name | ||
127 | .I k | ||
128 | must not contain =. | ||
129 | Spaces and tabs at the end of | ||
130 | .I v | ||
131 | are removed, and nulls in | ||
132 | .I v | ||
133 | are changed to newlines. | ||
134 | If the file | ||
135 | .I k | ||
136 | is empty (0 bytes long), | ||
137 | .B chpst | ||
138 | removes the environment variable | ||
139 | .I k | ||
140 | if it exists, without adding a new variable. | ||
141 | .TP | ||
142 | .B \-/ \fIroot | ||
143 | chroot. | ||
144 | Change the root directory to | ||
145 | .I root | ||
146 | before starting | ||
147 | .IR prog . | ||
148 | .TP | ||
149 | .B \-n \fIinc | ||
150 | nice. | ||
151 | Add | ||
152 | .I inc | ||
153 | to the | ||
154 | .BR nice (2) | ||
155 | value before starting | ||
156 | .IR prog . | ||
157 | .I inc | ||
158 | must be an integer, and may start with a minus or plus. | ||
159 | .TP | ||
160 | .B \-l \fIlock | ||
161 | lock. | ||
162 | Open the file | ||
163 | .I lock | ||
164 | for writing, and obtain an exclusive lock on it. | ||
165 | .I lock | ||
166 | will be created if it does not exist. | ||
167 | If | ||
168 | .I lock | ||
169 | is locked by another process, wait until a new lock can be obtained. | ||
170 | .TP | ||
171 | .B \-L \fIlock | ||
172 | The same as \-l, but fail immediately if | ||
173 | .I lock | ||
174 | is locked by another process. | ||
175 | .TP | ||
176 | .B \-m \fIbytes | ||
177 | limit memory. | ||
178 | Limit the data segment, stack segment, locked physical pages, and total of | ||
179 | all segment per process to | ||
180 | .I bytes | ||
181 | bytes each. | ||
182 | .TP | ||
183 | .B \-d \fIbytes | ||
184 | limit data segment. | ||
185 | Limit the data segment per process to | ||
186 | .I bytes | ||
187 | bytes. | ||
188 | .TP | ||
189 | .B \-o \fIn | ||
190 | limit open files. | ||
191 | Limit the number of open file descriptors per process to | ||
192 | .IR n . | ||
193 | .TP | ||
194 | .B \-p \fIn | ||
195 | limit processes. | ||
196 | Limit the number of processes per uid to | ||
197 | .IR n . | ||
198 | .TP | ||
199 | .B \-f \fIbytes | ||
200 | limit output size. | ||
201 | Limit the output file size to | ||
202 | .I bytes | ||
203 | bytes. | ||
204 | .TP | ||
205 | .B \-c \fIbytes | ||
206 | limit core size. | ||
207 | Limit the core file size to | ||
208 | .I bytes | ||
209 | bytes. | ||
210 | .TP | ||
211 | .B \-v | ||
212 | verbose. | ||
213 | Print verbose messages to standard error. | ||
214 | This includes warnings about limits unsupported by the system. | ||
215 | .TP | ||
216 | .B \-P | ||
217 | pgrphack. | ||
218 | Run | ||
219 | .I prog | ||
220 | in a new process group. | ||
221 | .TP | ||
222 | .B \-0 | ||
223 | Close standard input before starting | ||
224 | .IR prog . | ||
225 | .TP | ||
226 | .B \-1 | ||
227 | Close standard output before starting | ||
228 | .IR prog . | ||
229 | .TP | ||
230 | .B \-2 | ||
231 | Close standard error before starting | ||
232 | .IR prog . | ||
233 | .SH EXIT CODES | ||
234 | .B chpst | ||
235 | exits 100 when called with wrong options. | ||
236 | It prints an error message and exits 111 if it has trouble changing the | ||
237 | process state. | ||
238 | Otherwise its exit code is the same as that of | ||
239 | .IR prog . | ||
240 | .SH EMULATION | ||
241 | If | ||
242 | .B chpst | ||
243 | is called as | ||
244 | .BR envdir , | ||
245 | .BR envuidgid , | ||
246 | .BR pgrphack , | ||
247 | .BR setlock , | ||
248 | .BR setuidgid , | ||
249 | or | ||
250 | .BR softlimit , | ||
251 | it emulates the functionality of these programs from the daemontools package | ||
252 | respectively. | ||
253 | .SH SEE ALSO | ||
254 | sv(8), | ||
255 | runsv(8), | ||
256 | setsid(2), | ||
257 | runit(8), | ||
258 | runit-init(8), | ||
259 | runsvdir(8), | ||
260 | runsvchdir(8) | ||
261 | .P | ||
262 | http://smarden.org/runit/ | ||
263 | http://cr.yp.to/daemontools.html | ||
264 | .SH AUTHOR | ||
265 | Gerrit Pape <pape@smarden.org> | ||