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