1prctl(1) User Commands prctl(1)
2
3
4
6 prctl - get or set the resource controls of running processes, tasks,
7 and projects
8
10 prctl [-P] [-t [basic | privileged | system]]
11 [-n name [-srx] [-v value] [-e | -d action] [-p pid]]
12 [-i idtype] id...
13
14
16 The prctl utility allows the examination and modification of the
17 resource controls associated with an active process, task, or project
18 on the system. It allows access to the basic and privileged limits and
19 the current usage on the specified entity.
20
21
22 See resource_controls(5) for a description of the resource controls
23 supported in the current release of the Solaris operating system.
24
26 If none of the -s, -r, -x, -v, -d, or -e options are specified, the
27 invocation is considered a get operation. Otherwise, it is considered a
28 modify operation.
29
30
31 The following options are supported:
32
33 -d | -e action
34
35 Disables (-d) or enables (-e) the specified action on the resource
36 control value specified by -v, -t, and -p. If any of the -v, -t, or
37 -p options are unspecified, they match any value, privilege, or
38 recipient pid. For example, specifying only -v modifies the first
39 resource control with matching value, matching any privilege and
40 recipient pid. If no matching resource control value is found, a
41 new value is added as if -s were specified.
42
43 Actions:
44
45 all This action is only available with -d. It disables
46 all actions. This fails on resource control values
47 that have the deny global flag.
48
49
50 deny Indicates that the resource control attempts to
51 deny granting the resource to the process, task,
52 project, or zone on a request for resources in
53 excess of the resource control value. deny actions
54 can not be enabled if the resource control has the
55 no-deny global flag. deny actions can not be dis‐
56 abled if the resource control has the deny global
57 flag.
58
59
60 signal This action is only available with -d. It deacti‐
61 vates the signal action.
62
63
64 signal=signum In the signal=signum action, signum is a signal
65 number (or string representation of a signal).
66 Setting a signal action on a resource control with
67 the no-local-action global flag fails. A limited
68 set of signals can be sent. See NOTES for addi‐
69 tional details.
70
71
72
73 -i idtype
74
75 Specifies the type of the id operands. Valid idtypes are process,
76 task, project, or zone. Also allowed are pid, taskid, projid, and
77 zoneid. The default id type, if the -i option is omitted, is
78 process.
79
80 For a modify operation, the entity to which id operands are members
81 is the target entity. For instance, setting a project resource con‐
82 trol on an -i process sets the resource control on the project to
83 which each given process argument is a member.
84
85 For a get operation, the resource controls are listed for all enti‐
86 ties to which the id operands are members. For example, -i task
87 taskid lists the task, project, and zone resource controls for the
88 task, and for the project and zone to which that task is a member.
89
90
91 -n name
92
93 Specifies the name of the resource control to get or set. If the
94 name is unspecified, all resource controls are retrieved.
95
96
97 -p pid
98
99 When manipulating (using -s, -r, -x, -d, or -e) a basic task
100 project, or zone resource control values, a recipient pid can be
101 specified using -p. When setting a new basic resource control or
102 controls on a task, project, or zone, the -p option is required if
103 the -i idtype option argument is not process.
104
105
106 -P
107
108 Display resource control values in space delimited format.
109
110
111 -r
112
113 Replaces the first resource control value (matching with the -t
114 privilege) with the new value specified through the -v option.
115
116
117 -s
118
119 Set a new resource control value.
120
121 This option requires the -v option.
122
123 If you do not specify the -t option, basic privilege is used. If
124 you want to set a basic task, process, or zone rctl, -p is
125 required. If -e or -d are also specified, the action on the new
126 rctl is set as well.
127
128 For compatibility with prior releases, this option is implied if -v
129 is specified, without any of -e, -d, -r, or -x.
130
131 See resource_controls(5) for a description of unit modifiers and
132 scaling factors you can use to express large values when setting a
133 resource control value.
134
135
136 -t [ basic | privileged | system ]
137
138 Specifies which resource control type to set. Unless the "lower‐
139 able" flag is set for a resource control, only invocations by users
140 (or setuid programs) who have privileges equivalent to those of
141 root can modify privileged resource controls. See rctl‐
142 blk_set_value(3C) for a description of the RCTL_GLOBAL_LOWERABLE
143 flag. If the type is not specified, basic is assumed. For a get
144 operation, the values of all resource control types, including sys‐
145 tem, are displayed if no type is specified.
146
147
148 -v value
149
150 Specifies the value for the resource control for a set operation.
151 If no value is specified, then the modification (deletion, action
152 enabling or disabling) is carried out on the lowest-valued resource
153 control with the given type.
154
155 See resource_controls(5) for a description of unit modifiers and
156 scaling factors you can use to express large values when setting a
157 resource control value.
158
159
160 -x
161
162 Deletes the specified resource control value. If the delete option
163 is not provided, the default operation of prctl is to modify a
164 resource control value of matching value and privilege, or insert a
165 new value with the given privilege. The matching criteria are dis‐
166 cussed more fully in setrctl(2).
167
168
169
170 If none of the -d, -e, -v, or -x options is specified, the invocation
171 is considered a get operation.
172
174 The following operand is supported:
175
176 id The ID of the entity (process, task, project, or zone) to inter‐
177 rogate. If the invoking user's credentials are unprivileged and
178 the entity being interrogated possesses different credentials,
179 the operation fails. If no id is specified, an error message is
180 returned.
181
182
184 Example 1 Displaying Current Resource Control Settings
185
186
187 The following example displays current resource control settings for a
188 task to which the current shell belongs:
189
190
191 example$ ps -o taskid -p $$
192 TASKID
193 8
194 example$ prctl -i task 8
195 136150: /bin/ksh
196 NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
197 task.max-cpu-time
198 usage 8s
199 system 18.4Es inf none -
200 task.max-lwps
201 usage 39
202 system 2.15G max deny -
203 project.max-contracts
204 privileged 10.0K - deny -
205 project.max-locked-memory
206 usage 0B
207 privileged 508MB - deny -
208 project.max-port-ids
209 privileged 8.19K - deny -
210 project.max-shm-memory
211 privileged 508MB - deny -
212 project.max-shm-ids
213 privileged 128 - deny -
214 project.max-msg-ids
215 privileged 128 - deny -
216 project.max-sem-ids
217 privileged 128 - deny -
218 project.max-crypto-memory
219 usage 0B
220 privileged 508MB - deny -
221 project.max-tasks
222 usage 2
223 system 2.15G max deny -
224 project.max-lwps
225 usage 39
226 system 2.15G max deny -
227 project.cpu-shares
228 usage 1
229 privileged 1 - none -
230 zone.max-shm-memory
231 system 16.0EB max deny -
232 zone.max-shm-ids
233 system 16.8M max deny -
234 zone.max-sem-ids
235 system 16.8M max deny -
236 zone.max-msg-ids
237 system 16.8M max deny -
238 zone.max-lwps
239 system 2.15G max deny -
240 zone.cpu-shares
241 privileged 1 - none -
242 zone.max-locked-memory
243 usage 0B
244 privileged 508MB - deny -
245
246
247
248 Example 2 Displaying, Replacing, and Verifying the Value of a Specific
249 Control
250
251
252 The following examples displays, replaces, and verifies the value of a
253 specific control on an existing project:
254
255
256 example# prctl -n project.cpu-shares -i project group.staff
257 project: 10: group.staff
258 NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
259 project.cpu-shares
260 usage 1
261 privileged 1 - none -
262 system 65.5K max none -
263
264 example# prctl -n project.cpu-shares -v 10 -r -i project group.staff
265 example# prctl -n project.cpu-shares -i project group.staff
266 project: 10: group.staff
267 NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
268 project.cpu-shares
269 usage 10
270 privileged 10 - none -
271 system 65.5K max none -
272
273
274
275 Example 3 Adjusting Resources
276
277
278 The following example uses the project.max-locked-memory resource.
279
280
281
282 First, use id -p to find out which project the current shell is a mem‐
283 ber of:
284
285
286 /home/garfield> id -p
287 uid=77880(garfield) gid=10(staff) projid=10(group.staff)
288
289
290
291
292 Using the target project, identify the resource limit value before the
293 change:
294
295
296 /home/garfield> prctl -n project.max-locked-memory -i project \
297 group.staff
298 project 10: group.staff
299 project.max-locked-memory
300 privileged 256MB - deny -
301 system 16.0EB max deny -
302
303 current limit is 256 Megabytes.
304
305
306
307
308 Next, adjust the project.max-locked-memory limit to 300 Megabytes for
309 the target project:
310
311
312 # prctl -n project.max-locked-memory -v 300M -r -i project group.staff
313
314
315
316
317 The resource limit value after the change shows a new value of 300
318 Megabytes:
319
320
321 # prctl -n project.max-locked-memory -i project group.staff
322 project 10:group.staff
323 project.max-locked-memory
324 usage 200MG
325 privileged 300MB - deny -
326 system 16.0EB max deny -
327
328
329
330 Example 4 Modifying CPU Caps for a Project
331
332
333 The prctl command can use the project.cpu-cap resource control (see
334 resource_controls(5)) to set and modify CPU caps for a project. (The
335 same resource control can be used in the /etc/project file. See
336 project(4)) The following command modifies the CPU cap to limit
337 user.smith to three CPUs:
338
339
340 # prctl -r -t privileged -n project.cpu-cap -v 300 -i project user.smith
341
342
343
344
345 The prctl -r option, used above, is used to dynamically change a CPU
346 cap for a project or zone. For example, the following command will
347 change the cap set in the preceding command to 80 percent:
348
349
350 # prctl -r -t privileged -n project.cpu-cap -v 80 -i project user.smith
351
352
353
354
355 To remove a CPU cap, enter:
356
357
358 # prctl -x -n project.cpu-cap $$
359
360
361
362 Example 5 Modifying CPU Caps for a Zone
363
364
365 The prctl command can use the zone.cpu-cap resource control (see
366 resource_controls(5)) to set and modify CPU caps for a zone. (The same
367 resource control can be manipulated using the zonecfg(1M) command.) The
368 following command modifies the CPU cap to limit the global zone to 80
369 percent of a CPU:
370
371
372 # prctl -t privileged -n zone.cpu-cap -v 80 -i zone global
373
374
375
376
377 The cap can be lowered to 50% using:
378
379
380 # prctl -r -t privileged -n zone.cpu-cap -v 50 -i zone global
381
382
383
385 The following exit values are returned:
386
387 0 Success.
388
389
390 1 Fatal error encountered.
391
392
393 2 Invalid command line options were specified.
394
395
397 /proc/pid/* Process information and control files
398
399
401 See attributes(5) for descriptions of the following attributes:
402
403
404
405
406 ┌─────────────────────────────┬─────────────────────────────┐
407 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
408 ├─────────────────────────────┼─────────────────────────────┤
409 │Availability │SUNWesu │
410 ├─────────────────────────────┼─────────────────────────────┤
411 │Interface Stability │See below. │
412 └─────────────────────────────┴─────────────────────────────┘
413
414
415 The command-line syntax is Committed. The human-readable output is
416 Uncommitted. The parseable output is Committed.
417
419 rctladm(1M), zonecfg(1M), setrctl(2), rctlblk_get_local_action(3C),
420 project(4), attributes(5), resource_controls(5)
421
423 The valid signals that can be set on a resource control block allowing
424 local actions are SIGABRT, SIGXRES, SIGHUP, SIGSTOP, SIGTERM, and
425 SIGKILL. Additionally, CPU time related controls can issue the SIGXCPU
426 signal, and file size related controls can send the SIGXFSZ signal.
427
428
429
430SunOS 5.11 25 Aug 2009 prctl(1)