Merge commit 'b31320a79e2054c6739b5229259dbf98f3afc547' into merges
[unleashed.git] / share / man / man1 / prctl.1
blob3991736d300c72c344332d91390007f0f1157c71
1 '\" te
2 .\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
4 .\"  See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with
5 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH PRCTL 1 "April 9, 2016"
7 .SH NAME
8 prctl \- get or set the resource controls of running processes, tasks, and
9 projects
10 .SH SYNOPSIS
11 .LP
12 .nf
13 \fBprctl\fR [\fB-P\fR] [\fB-t\fR [basic | privileged | system]]
14      [\fB-n\fR \fIname\fR [\fB-srx\fR] [\fB-v\fR \fIvalue\fR] [\fB-e\fR | \fB-d\fR \fIaction\fR] [\fB-p\fR \fIpid\fR]]
15      [\fB-i\fR \fIidtype\fR] \fIid\fR...
16 .fi
18 .SH DESCRIPTION
19 .LP
20 The \fBprctl\fR utility allows the examination and modification of the resource
21 controls associated with an active process, task, or project on the system. It
22 allows access to the  basic and privileged limits and the  current  usage  on
23 the     specified entity.
24 .sp
25 .LP
26 See \fBresource_controls\fR(5) for a description of the resource controls
27 supported in the current release of the Solaris operating system.
28 .SH OPTIONS
29 .LP
30 The following options are supported:
31 .sp
32 .ne 2
33 .na
34 \fB\fB-d\fR | \fB-e\fR \fIaction\fR\fR
35 .ad
36 .sp .6
37 .RS 4n
38 Disables (\fB-d\fR) or enables (\fB-e\fR) the specified \fIaction\fR on the
39 resource control value specified by \fB-v\fR, \fB-t\fR, and \fB-p\fR. If any of
40 the \fB-v\fR, \fB-t\fR, or \fB-p\fR options are unspecified, they match any
41 value, privilege, or recipient pid. For example, specifying only \fB-v\fR
42 modifies the first resource control with matching value, matching any privilege
43 and recipient pid. If no matching resource control value is found, a new value
44 is added as if \fB-s\fR were specified.
45 .sp
46 \fBActions:\fR
47 .sp
48 .ne 2
49 .na
50 \fB\fBall\fR\fR
51 .ad
52 .RS 17n
53 This action is only available with \fB-d\fR. It disables all actions. This
54 fails on resource control values that have the \fBdeny\fR global flag.
55 .RE
57 .sp
58 .ne 2
59 .na
60 \fB\fBdeny\fR\fR
61 .ad
62 .RS 17n
63 Indicates that the resource control attempts to deny granting the resource to
64 the process, task, project, or zone on a request for resources in excess of the
65 resource control value. \fBdeny\fR actions can not be enabled if the resource
66 control has the \fBno-deny\fR global flag. \fBdeny\fR actions can not be
67 disabled if the resource control has the \fBdeny\fR global flag.
68 .RE
70 .sp
71 .ne 2
72 .na
73 \fB\fBsignal\fR\fR
74 .ad
75 .RS 17n
76 This action is only available with \fB-d\fR. It deactivates the \fBsignal\fR
77 action.
78 .RE
80 .sp
81 .ne 2
82 .na
83 \fB\fBsignal\fR=\fIsignum\fR\fR
84 .ad
85 .RS 17n
86 In the \fBsignal=\fR\fIsignum\fR action, \fIsignum\fR is a signal number (or
87 string representation of a signal). Setting a \fBsignal\fR action on a resource
88 control with the \fBno-local-action\fR global flag fails. A limited set of
89 signals can be sent. See \fBNOTES\fR for additional details.
90 .RE
92 .RE
94 .sp
95 .ne 2
96 .na
97 \fB\fB-i\fR \fIidtype\fR\fR
98 .ad
99 .sp .6
100 .RS 4n
101 Specifies the type of the id operands. Valid \fIidtype\fRs are \fBprocess\fR,
102 \fBtask\fR, \fBproject\fR, or \fBzone\fR. Also allowed are \fBpid\fR,
103 \fBtaskid\fR, \fBprojid\fR, and \fBzoneid\fR. The default id type, if the
104 \fB-i\fR option is omitted, is \fBprocess\fR.
106 For a modify operation, the entity to which id operands are members is the
107 target entity. For instance, setting a project resource control on an \fB-i\fR
108 \fBprocess\fR sets the resource control on the project to which each given
109 process argument is a member.
111 For a get operation, the resource controls are listed for all entities to which
112 the id operands are members. For example, \fB-i\fR \fBtask\fR \fItaskid\fR
113 lists the task, project, and zone resource controls for the task, and for the
114 project and zone to which that task is a member.
118 .ne 2
120 \fB\fB-n\fR \fIname\fR\fR
122 .sp .6
123 .RS 4n
124 Specifies the name of the resource control to get or set. If the \fIname\fR is
125 unspecified, all resource controls are retrieved.
129 .ne 2
131 \fB\fB-p\fR \fIpid\fR\fR
133 .sp .6
134 .RS 4n
135 When manipulating (using \fB-s\fR, \fB-r\fR, \fB-x\fR, \fB-d\fR, or \fB-e\fR) a
136 basic task project, or zone resource control values, a recipient \fIpid\fR can
137 be specified using \fB-p\fR. When setting a new basic resource control or
138 controls on a task, project, or zone, the \fB-p\fR option is required if the
139 \fB-i\fR \fIidtype\fR option argument is not \fBprocess\fR.
143 .ne 2
145 \fB\fB-P\fR\fR
147 .sp .6
148 .RS 4n
149 Display resource control values in space delimited format.
153 .ne 2
155 \fB\fB-r\fR\fR
157 .sp .6
158 .RS 4n
159 Replaces the first resource control value (matching with the \fB-t\fR
160 \fBprivilege\fR) with the new value specified through the \fB-v\fR option.
164 .ne 2
166 \fB\fB-s\fR\fR
168 .sp .6
169 .RS 4n
170 Set a new resource control value.
172 This option requires the \fB-v\fR option.
174 If you do not specify the \fB-t\fR option, basic privilege is used. If you want
175 to set a basic task, process, or zone rctl, \fB-p\fR is required. If \fB-e\fR
176 or \fB-d\fR are also specified, the action on the new \fBrctl\fR is set as
177 well.
179 For compatibility with prior releases, this option is implied if \fB-v\fR is
180 specified, without any of \fB-e\fR, \fB-d\fR, \fB-r\fR, or \fB-x\fR.
182 See \fBresource_controls\fR(5) for a description of unit modifiers and scaling
183 factors you can use to express large values when setting a resource control
184 value.
188 .ne 2
190 \fB\fB-t\fR [ \fBbasic\fR | \fBprivileged\fR | \fBsystem\fR ]\fR
192 .sp .6
193 .RS 4n
194 Specifies which resource control type to set. Unless the "lowerable" flag is
195 set for a resource control, only invocations by users (or setuid programs) who
196 have privileges equivalent to those of root can modify privileged resource
197 controls. See \fBrctlblk_set_value\fR(3C) for a description of the
198 \fBRCTL_GLOBAL_LOWERABLE\fR flag. If the type is not specified, \fBbasic\fR is
199 assumed. For a get operation, the values of all resource control types,
200 including \fBsystem\fR, are displayed if no type is specified.
204 .ne 2
206 \fB\fB-v\fR \fIvalue\fR\fR
208 .sp .6
209 .RS 4n
210 Specifies the value for the resource control for a set operation. If no
211 \fIvalue\fR is specified, then the modification (deletion, action enabling or
212 disabling) is carried out on the lowest-valued resource control with the given
213 type.
215 See \fBresource_controls\fR(5) for a description of unit modifiers and scaling
216 factors you can use to express large values when setting a resource control
217 value.
221 .ne 2
223 \fB\fB-x\fR\fR
225 .sp .6
226 .RS 4n
227 Deletes the specified resource control value. If the delete option is not
228 provided, the default operation of \fBprctl\fR is to modify a resource control
229 value of matching value and privilege, or insert a new value with the given
230 privilege. The matching criteria are discussed more fully in \fBsetrctl\fR(2).
235 If none of the \fB-s\fR, \fB-r\fR, \fB-x\fR, \fB-v\fR, \fB-d\fR, or \fB-e\fR
236 options are specified, the invocation is considered a get operation. Otherwise,
237 it is considered a modify operation.
238 .SH OPERANDS
240 The following operand is supported:
242 .ne 2
244 \fB\fIid\fR\fR
246 .RS 6n
247 The \fBID\fR of the entity (\fBprocess\fR, \fBtask\fR, \fBproject\fR, or
248 \fBzone\fR) to interrogate. If the invoking user's credentials are unprivileged
249 and the entity being interrogated possesses different credentials, the
250 operation fails. If no \fIid\fR is specified, an error message is returned.
253 .SH EXAMPLES
255 \fBExample 1 \fRDisplaying Current Resource Control Settings
258 The following example displays current resource control settings for a task to
259 which the current shell belongs:
262 .in +2
264  example$ ps -o taskid -p $$
265 TASKID
267 example$ prctl -i task 8
268 136150: /bin/ksh
269 NAME    PRIVILEGE       VALUE    FLAG   ACTION             RECIPIENT
270 task.max-cpu-time
271         usage            8s
272         system          18.4Es    inf   none                -
273 task.max-lwps
274         usage              39
275         system          2.15G     max   deny                -
276 project.max-contracts
277         privileged      10.0K       -   deny                -
278 project.max-locked-memory
279         usage               0B
280         privileged       508MB      -   deny                -
281 project.max-port-ids
282         privileged      8.19K       -   deny                -
283 project.max-shm-memory
284         privileged       508MB      -   deny                -
285 project.max-shm-ids
286         privileged        128       -   deny                -
287 project.max-msg-ids
288         privileged        128       -   deny                -
289 project.max-sem-ids
290         privileged        128       -   deny                -
291 project.max-crypto-memory
292          usage            0B
293 privileged       508MB      -   deny                -
294 project.max-tasks
295         usage               2
296         system          2.15G     max   deny                -
297 project.max-lwps
298          usage             39
299         system          2.15G     max   deny                -
300 project.cpu-shares
301         usage               1
302         privileged          1       -   none                -
303 zone.max-shm-memory
304         system          16.0EB    max   deny                -
305 zone.max-shm-ids
306         system          16.8M     max   deny                -
307 zone.max-sem-ids
308         system          16.8M     max   deny                -
309 zone.max-msg-ids
310         system          16.8M     max   deny                -
311 zone.max-lwps
312         system          2.15G     max   deny                -
313 zone.cpu-shares
314         privileged          1       -   none                -
315 zone.max-locked-memory
316         usage               0B
317         privileged       508MB      -   deny                -
319 .in -2
323 \fBExample 2 \fRDisplaying, Replacing, and Verifying the Value of a Specific
324 Control
327 The following examples displays, replaces, and verifies the value of a specific
328 control on an existing project:
331 .in +2
333 example# prctl -n project.cpu-shares -i project group.staff
334 project: 10: group.staff
335 NAME    PRIVILEGE       VALUE    FLAG   ACTION               RECIPIENT
336 project.cpu-shares
337         usage               1
338         privileged          1       -   none                         -
339         system          65.5K     max   none                         -
341 example# prctl -n project.cpu-shares -v 10 -r -i project group.staff
342 example# prctl -n project.cpu-shares -i project group.staff
343 project: 10: group.staff
344 NAME    PRIVILEGE       VALUE    FLAG   ACTION               RECIPIENT
345 project.cpu-shares
346         usage              10
347         privileged         10       -   none                         -
348         system          65.5K     max   none                         -
350 .in -2
354 \fBExample 3 \fRAdjusting Resources
357 The following example uses the \fBproject.max-locked-memory\fR resource.
361 First, use \fBid\fR \fB-p\fR to find out which project the current shell is a
362 member of:
365 .in +2
367 /home/garfield> id -p
368           uid=77880(garfield) gid=10(staff) projid=10(group.staff)
370 .in -2
375 Using the target project, identify the resource limit value before the change:
378 .in +2
380 /home/garfield> prctl -n project.max-locked-memory -i project \e
381                       group.staff
382         project 10: group.staff
383         project.max-locked-memory
384             privileged         256MB       -    deny                  -
385             system            16.0EB     max    deny                  -
387 current limit is 256 Megabytes.
389 .in -2
394 Next, adjust the \fBproject.max-locked-memory\fR limit to 300 Megabytes for the
395 target project:
398 .in +2
400 # prctl -n project.max-locked-memory -v 300M -r -i project group.staff
402 .in -2
407 The resource limit value after the change shows a new value of 300 Megabytes:
410 .in +2
412 # prctl -n project.max-locked-memory -i project group.staff
413         project 10:group.staff
414         project.max-locked-memory
415             usage              200MG
416      privileged         300MB       -    deny                           -
417            system            16.0EB     max    deny                           -
419 .in -2
423 \fBExample 4 \fRModifying CPU Caps for a Project
426 The \fBprctl\fR command can use the \fBproject.cpu-cap\fR resource control (see
427 \fBresource_controls\fR(5)) to set and modify CPU caps for a project. (The same
428 resource control can be used in the \fB/etc/project\fR file. See
429 \fBproject\fR(4)) The following command modifies the CPU cap to limit
430 \fBuser.smith\fR  to three CPUs:
433 .in +2
435 # \fBprctl -r -t privileged -n project.cpu-cap -v 300 -i project user.smith\fR
437 .in -2
442 The \fBprctl\fR \fB-r\fR option, used above, is used to dynamically change a
443 CPU cap for a project or zone. For example, the following command will change
444 the cap set in the preceding command to 80 percent:
447 .in +2
449 # \fBprctl -r -t privileged -n project.cpu-cap -v 80 -i project user.smith\fR
451 .in -2
456 To remove a CPU cap, enter:
459 .in +2
461 # \fBprctl -x -n project.cpu-cap $$\fR
463 .in -2
467 \fBExample 5 \fRModifying CPU Caps for a Zone
470 The \fBprctl\fR command can use the \fBzone.cpu-cap\fR resource control (see
471 \fBresource_controls\fR(5)) to set and modify CPU caps for a zone. (The same
472 resource control can be manipulated using the \fBzonecfg\fR(8) command.) The
473 following command modifies the CPU cap to limit the global zone to 80 percent
474 of a CPU:
477 .in +2
479 # \fBprctl -t privileged -n zone.cpu-cap -v 80 -i zone global\fR
481 .in -2
486 The cap can be lowered to 50% using:
489 .in +2
491 # \fBprctl -r -t privileged -n zone.cpu-cap -v 50 -i zone global\fR
493 .in -2
496 .SH EXIT STATUS
498 The following exit values are returned:
500 .ne 2
502 \fB\fB0\fR\fR
504 .RS 5n
505 Success.
509 .ne 2
511 \fB\fB1\fR\fR
513 .RS 5n
514 Fatal error encountered.
518 .ne 2
520 \fB\fB2\fR\fR
522 .RS 5n
523 Invalid command line options were specified.
526 .SH FILES
527 .ne 2
529 \fB\fB/proc/pid/*\fR\fR
531 .RS 15n
532 Process information and control files
535 .SH ATTRIBUTES
537 See \fBattributes\fR(5) for descriptions of the following attributes:
542 box;
543 c | c
544 l | l .
545 ATTRIBUTE TYPE  ATTRIBUTE VALUE
547 Interface Stability     See below.
552 The command-line syntax is Committed. The human-readable output is Uncommitted.
553 The parsable output is Committed.
554 .SH SEE ALSO
556 \fBrctladm\fR(8), \fBzonecfg\fR(8), \fBsetrctl\fR(2),
557 \fBrctlblk_get_local_action\fR(3C), \fBproject\fR(4), \fBattributes\fR(5),
558 \fBresource_controls\fR(5)
559 .SH NOTES
561 The valid signals that can be set on a resource control block allowing local
562 actions are \fBSIGABRT\fR, \fBSIGXRES\fR, \fBSIGHUP\fR, \fBSIGSTOP\fR,
563 \fBSIGTERM\fR, and \fBSIGKILL\fR. Additionally, CPU time related controls can
564 issue the \fBSIGXCPU\fR signal, and file size related controls can send the
565 \fBSIGXFSZ\fR signal.