Print this page
7264 Example code is rctlblk_set_value(3c) manpage does not compile.
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man3c/rctlblk_set_value.3c
+++ new/usr/src/man/man3c/rctlblk_set_value.3c
1 1 '\" te
2 2 .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
3 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.
4 4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 5 .\" 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 the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 -.TH RCTLBLK_SET_VALUE 3C "May 15, 2006"
6 +.TH RCTLBLK_SET_VALUE 3C "Aug 2, 2016"
7 7 .SH NAME
8 8 rctlblk_set_value, rctlblk_get_firing_time, rctlblk_get_global_action,
9 9 rctlblk_get_global_flags, rctlblk_get_local_action, rctlblk_get_local_flags,
10 10 rctlblk_get_privilege, rctlblk_get_recipient_pid, rctlblk_get_value,
11 11 rctlblk_get_enforced_value, rctlblk_set_local_action, rctlblk_set_local_flags,
12 12 rctlblk_set_privilege, rctlblk_set_recipient_pid, rctlblk_size \- manipulate
13 13 resource control blocks
14 14 .SH SYNOPSIS
15 15 .LP
16 16 .nf
17 17 #include <rctl.h>
18 18
19 19 \fBhrtime_t\fR \fBrctlblk_get_firing_time\fR(\fBrctlblk_t *\fR\fIrblk\fR);
20 20 .fi
21 21
22 22 .LP
23 23 .nf
24 24 \fBint\fR \fBrctlblk_get_global_action\fR(\fBrctlblk_t *\fR\fIrblk\fR);
25 25 .fi
26 26
27 27 .LP
28 28 .nf
29 29 \fBint\fR \fBrctlblk_get_global_flags\fR(\fBrctlblk_t *\fR\fIrblk\fR);
30 30 .fi
31 31
32 32 .LP
33 33 .nf
34 34 \fBint\fR \fBrctlblk_get_local_action\fR(\fBrctlblk_t *\fR\fIrblk\fR, \fBint *\fR\fIsignalp\fR);
35 35 .fi
36 36
37 37 .LP
38 38 .nf
39 39 \fBint\fR \fBrctlblk_get_local_flags\fR(\fBrctlblk_t *\fR\fIrblk\fR);
40 40 .fi
41 41
42 42 .LP
43 43 .nf
44 44 \fBrctl_priv_t\fR \fBrctlblk_get_privilege\fR(\fBrctlblk_t *\fR\fIrblk\fR);
45 45 .fi
46 46
47 47 .LP
48 48 .nf
49 49 \fBid_t\fR \fBrctlblk_get_recipient_pid\fR(\fBrctlblk_t *\fR\fIrblk\fR);
50 50 .fi
51 51
52 52 .LP
53 53 .nf
54 54 \fBrctl_qty_t\fR \fBrctlblk_get_value\fR(\fBrctlblk_t *\fR\fIrblk\fR);
55 55 .fi
56 56
57 57 .LP
58 58 .nf
59 59 \fBrctl_qty_t\fR \fBrctlblk_get_enforced_value\fR(\fBrctlblk_t *\fR\fIrblk\fR);
60 60 .fi
61 61
62 62 .LP
63 63 .nf
64 64 \fBvoid\fR \fBrctlblk_set_local_action\fR(\fBrctlblk_t *\fR\fIrblk\fR, \fBrctl_action_t\fR \fIaction\fR,
65 65 \fBint\fR \fIsignal\fR);
66 66 .fi
67 67
68 68 .LP
69 69 .nf
70 70 \fBvoid\fR \fBrctlblk_set_local_flags\fR(\fBrctlblk_t *\fR\fIrblk\fR, \fBint\fR \fIflags\fR);
71 71 .fi
72 72
73 73 .LP
74 74 .nf
75 75 \fBvoid\fR \fBrctlblk_set_privilege\fR(\fBrctlblk_t *\fR\fIrblk\fR, \fBrctl_priv_t\fR \fIprivilege\fR);
76 76 .fi
77 77
78 78 .LP
79 79 .nf
80 80 \fBvoid\fR \fBrctlblk_set_value\fR(\fBrctlblk_t *\fR\fIrblk\fR, \fBrctl_qty_t\fR \fIvalue\fR);
81 81 .fi
82 82
83 83 .LP
↓ open down ↓ |
67 lines elided |
↑ open up ↑ |
84 84 .nf
85 85 \fBvoid\fR \fBrctlblk_set_recipient_pid\fR(\fBid_t\fR\fIpid\fR);
86 86 .fi
87 87
88 88 .LP
89 89 .nf
90 90 \fBsize_t\fR \fBrctlblk_size\fR(\fBvoid\fR);
91 91 .fi
92 92
93 93 .SH DESCRIPTION
94 -.sp
95 94 .LP
96 95 The resource control block routines allow the establishment or retrieval of
97 96 values from a resource control block used to transfer information using the
98 97 \fBgetrctl\fR(2) and \fBsetrctl\fR(2) functions. Each of the routines accesses
99 98 or sets the resource control block member corresponding to its name. Certain
100 99 of these members are read-only and do not possess set routines.
101 100 .sp
102 101 .LP
103 102 The firing time of a resource control block is 0 if the resource control
104 103 action-value has not been exceeded for its lifetime on the process. Otherwise
105 104 the firing time is the value of \fBgethrtime\fR(3C) at the moment the action on
106 105 the resource control value was taken.
107 106 .sp
108 107 .LP
109 108 The global actions and flags are the action and flags set by \fBrctladm\fR(1M).
110 109 These values cannot be set with \fBsetrctl\fR(2). Valid global actions are
111 110 listed in the table below. Global flags are generally a published property of
112 111 the control and are not modifiable.
113 112 .sp
114 113 .ne 2
115 114 .na
116 115 \fB\fBRCTL_GLOBAL_DENY_ALWAYS\fR\fR
117 116 .ad
118 117 .RS 28n
119 118 The action taken when a control value is exceeded on this control will always
120 119 include denial of the resource.
121 120 .RE
122 121
123 122 .sp
124 123 .ne 2
125 124 .na
126 125 \fB\fBRCTL_GLOBAL_DENY_NEVER\fR\fR
127 126 .ad
128 127 .RS 28n
129 128 The action taken when a control value is exceeded on this control will always
130 129 exclude denial of the resource; the resource will always be granted, although
131 130 other actions can also be taken.
132 131 .RE
133 132
134 133 .sp
135 134 .ne 2
136 135 .na
137 136 \fB\fBRCTL_GLOBAL_SIGNAL_NEVER\fR\fR
138 137 .ad
139 138 .RS 28n
140 139 No signal actions are permitted on this control.
141 140 .RE
142 141
143 142 .sp
144 143 .ne 2
145 144 .na
146 145 \fB\fBRCTL_GLOBAL_CPU_TIME\fR\fR
147 146 .ad
148 147 .RS 28n
149 148 The valid signals available as local actions include the \fBSIGXCPU\fR signal.
150 149 .RE
151 150
152 151 .sp
153 152 .ne 2
154 153 .na
155 154 \fB\fBRCTL_GLOBAL_FILE_SIZE\fR\fR
156 155 .ad
157 156 .RS 28n
158 157 The valid signals available as local actions include the \fBSIGXFSZ\fR signal.
159 158 .RE
160 159
161 160 .sp
162 161 .ne 2
163 162 .na
164 163 \fB\fBRCTL_GLOBAL_INFINITE\fR\fR
165 164 .ad
166 165 .RS 28n
167 166 This resource control supports the concept of an unlimited value; generally
168 167 true only of accumulation-oriented resources, such as CPU time.
169 168 .RE
170 169
171 170 .sp
172 171 .ne 2
173 172 .na
174 173 \fB\fBRCTL_GLOBAL_LOWERABLE\fR\fR
175 174 .ad
176 175 .RS 28n
177 176 Non-privileged callers are able to lower the value of privileged resource
178 177 control values on this control.
179 178 .RE
180 179
181 180 .sp
182 181 .ne 2
183 182 .na
184 183 \fB\fBRCTL_GLOBAL_NOACTION\fR\fR
185 184 .ad
186 185 .RS 28n
187 186 No global action will be taken when a resource control value is exceeded on
188 187 this control.
189 188 .RE
190 189
191 190 .sp
192 191 .ne 2
193 192 .na
194 193 \fB\fBRCTL_GLOBAL_NOBASIC\fR\fR
195 194 .ad
196 195 .RS 28n
197 196 No values with the \fBRCPRIV_BASIC\fR privilege are permitted on this control.
198 197 .RE
199 198
200 199 .sp
201 200 .ne 2
202 201 .na
203 202 \fB\fBRCTL_GLOBAL_SYSLOG\fR\fR
204 203 .ad
205 204 .RS 28n
206 205 A standard message will be logged by the \fBsyslog\fR(3C) facility when any
207 206 resource control value on a sequence associated with this control is exceeded.
208 207 .RE
209 208
210 209 .sp
211 210 .ne 2
212 211 .na
213 212 \fB\fBRCTL_GLOBAL_SYSLOG_NEVER\fR\fR
214 213 .ad
215 214 .RS 28n
216 215 The resource control does not support the \fBsyslog()\fR global action.
217 216 Exceeding a resource control value on this control will not result in a message
218 217 logged by the \fBsyslog()\fR facility.
219 218 .RE
220 219
221 220 .sp
222 221 .ne 2
223 222 .na
224 223 \fB\fBRCTL_GLOBAL_UNOBSERVABLE\fR\fR
225 224 .ad
226 225 .RS 28n
227 226 The resource control (generally on a task- or project-related control) does not
228 227 support observational control values. An \fBRCPRIV_BASIC\fR privileged control
229 228 value placed by a process on the task or process will generate an action only
230 229 if the value is exceeded by that process.
231 230 .RE
232 231
233 232 .sp
234 233 .ne 2
235 234 .na
236 235 \fB\fBRCTL_GLOBAL_BYTES\fR\fR
237 236 .ad
238 237 .RS 28n
239 238 This resource control represents a number of bytes.
240 239 .RE
241 240
242 241 .sp
243 242 .ne 2
244 243 .na
245 244 \fB\fBRCTL_GLOBAL_SECONDS\fR\fR
246 245 .ad
247 246 .RS 28n
248 247 This resource control represents a quantity of time in seconds.
249 248 .RE
250 249
251 250 .sp
252 251 .ne 2
253 252 .na
254 253 \fB\fBRCTL_GLOBAL_COUNT\fR\fR
255 254 .ad
256 255 .RS 28n
257 256 This resource control represents an integer count.
258 257 .RE
259 258
260 259 .sp
261 260 .LP
262 261 The local action and flags are those on the current resource control value
263 262 represented by this resource control block. Valid actions and flags are listed
264 263 in the table below. In the case of \fBRCTL_LOCAL_SIGNAL\fR, the second argument
265 264 to \fBrctlblk_set_local_action()\fR contains the signal to be sent. Similarly,
266 265 the signal to be sent is copied into the integer location specified by the
267 266 second argument to \fBrctlblk_get_local_action()\fR. A restricted set of
268 267 signals is made available for normal use by the resource control facility:
269 268 \fBSIGBART\fR, \fBSIGXRES\fR, \fBSIGHUP\fR, \fBSIGSTOP\fR, \fBSIGTERM\fR, and
270 269 \fBSIGKILL\fR. Other signals are permitted due to global properties of a
271 270 specific control. Calls to \fBsetrctl()\fR with illegal signals will fail.
272 271 .sp
273 272 .ne 2
274 273 .na
275 274 \fB\fBRCTL_LOCAL_DENY\fR\fR
276 275 .ad
277 276 .RS 23n
278 277 When this resource control value is encountered, the request for the resource
279 278 will be denied. Set on all values if \fBRCTL_GLOBAL_DENY_ALWAYS\fR is set for
280 279 this control; cleared on all values if \fBRCTL_GLOBAL_DENY_NEVER\fR is set for
281 280 this control.
282 281 .RE
283 282
284 283 .sp
285 284 .ne 2
286 285 .na
287 286 \fB\fBRCTL_LOCAL_MAXIMAL\fR\fR
288 287 .ad
289 288 .RS 23n
290 289 This resource control value represents a request for the maximum amount of
291 290 resource for this control. If \fBRCTL_GLOBAL_INFINITE\fR is set for this
292 291 resource control, \fBRCTL_LOCAL_MAXIMAL\fR indicates an unlimited resource
293 292 control value, one that will never be exceeded.
294 293 .RE
295 294
296 295 .sp
297 296 .ne 2
298 297 .na
299 298 \fB\fBRCTL_LOCAL_NOACTION\fR\fR
300 299 .ad
301 300 .RS 23n
302 301 No local action will be taken when this resource control value is exceeded.
303 302 .RE
304 303
305 304 .sp
306 305 .ne 2
307 306 .na
308 307 \fB\fBRCTL_LOCAL_SIGNAL\fR\fR
309 308 .ad
310 309 .RS 23n
311 310 The specified signal, sent by \fBrctlblk_set_local_action()\fR, will be sent to
312 311 the process that placed this resource control value in the value sequence. This
313 312 behavior is also true for signal actions on project and task resource controls.
314 313 The specified signal is sent only to the recipient process, not all processes
315 314 within the project or task.
316 315 .RE
317 316
318 317 .sp
319 318 .LP
320 319 The \fBrctlblk_get_recipient_pid()\fR function returns the value of the process
321 320 ID that placed the resource control value for basic rctls. For privileged or
322 321 system rctls, \fBrctlblk_get_recipient_pid()\fR returns -1.
323 322 .sp
324 323 .LP
325 324 The \fBrctlblk_set_recipient_pid()\fR function sets the recipient \fIpid\fR for
326 325 a basic rctl. When \fBsetrctl\fR(2) is called with the flag
327 326 \fBRCTL_USE_RECIPIENT_PID\fR, this \fIpid\fR is used. Otherwise, the PID of the
328 327 calling process is used. Only privileged users can set the recipient PID to one
329 328 other than the PID of the calling process. Process-scoped rctls must have a
330 329 recipient PID that matches the PID of the calling process.
331 330 .sp
332 331 .LP
333 332 The \fBrctlblk_get_privilege()\fR function returns the privilege of the
334 333 resource control block. Valid privileges are \fBRCPRIV_BASIC\fR,
335 334 \fBRCPRIV_PRIVILEGED\fR, and \fBRCPRIV_SYSTEM\fR. System resource controls are
336 335 read-only. Privileged resource controls require the {\fBPRIV_SYS_RESOURCE\fR}
337 336 privilege to write, unless the \fBRCTL_GLOBAL_LOWERABLE\fR global flag is set,
338 337 in which case unprivileged applications can lower the value of a privileged
339 338 control.
340 339 .sp
341 340 .LP
342 341 The \fBrctlblk_get_value()\fR and \fBrctlblk_set_value()\fR functions return or
343 342 establish the enforced value associated with the resource control. In cases
344 343 where the process, task, or project associated with the control possesses fewer
345 344 capabilities than allowable by the current value, the value returned by
346 345 \fBrctlblk_get_enforced_value()\fR will differ from that returned by
↓ open down ↓ |
242 lines elided |
↑ open up ↑ |
347 346 \fBrctlblk_get_value()\fR. This capability difference arises with processes
348 347 using an address space model smaller than the maximum address space model
349 348 supported by the system.
350 349 .sp
351 350 .LP
352 351 The \fBrctlblk_size()\fR function returns the size of a resource control block
353 352 for use in memory allocation. The \fBrctlblk_t *\fR type is an opaque pointer
354 353 whose size is not connected with that of the resource control block itself. Use
355 354 of \fBrctlblk_size()\fR is illustrated in the example below.
356 355 .SH RETURN VALUES
357 -.sp
358 356 .LP
359 357 The various set routines have no return values. Incorrectly composed resource
360 358 control blocks will generate errors when used with \fBsetrctl\fR(2) or
361 359 \fBgetrctl\fR(2).
362 360 .SH ERRORS
363 -.sp
364 361 .LP
365 362 No error values are returned. Incorrectly constructed resource control blocks
366 363 will be rejected by the system calls.
367 364 .SH EXAMPLES
368 365 .LP
369 366 \fBExample 1 \fRDisplay the contents of a fetched resource control block.
370 367 .sp
371 368 .LP
372 369 The following example displays the contents of a fetched resource control
373 370 block.
374 371
375 372 .sp
376 373 .in +2
377 374 .nf
378 375 #include <rctl.h>
379 376 #include <stdio.h>
380 377 #include <stdlib.h>
381 378
382 -rctlblk_t *rblk;
383 -int rsignal;
384 -int raction;
379 +int
380 +main()
381 +{
382 + rctlblk_t *rblk;
383 + int rsignal, raction;
385 384
386 -if ((rblk = malloc(rctlblk_size())) == NULL) {
387 - (void) perror("rblk malloc");
388 - exit(1);
389 -}
385 + if ((rblk = malloc(rctlblk_size())) == NULL) {
386 + (void) perror("rblk malloc");
387 + exit(1);
388 + }
390 389
391 -if (getrctl("process.max-cpu-time", NULL, rblk, RCTL_FIRST) == -1) {
392 - (void) perror("getrctl");
393 - exit(1);
394 -}
390 + if (getrctl("process.max-cpu-time", NULL, rblk, RCTL_FIRST) == -1) {
391 + (void) perror("getrctl");
392 + exit(1);
393 + }
395 394
396 -main()
397 -{
398 - raction = rctlblk_get_local_action(rblk, &rsignal),
399 - (void) printf("Resource control for %s\en",
400 - "process.max-cpu-time");
401 - (void) printf("Process ID: %d\en",
402 - rctlblk_get_recipient_pid(rblk));
403 - (void) printf("Privilege: %x\en"
404 - rctlblk_get_privilege(rblk));
405 - (void) printf("Global flags: %x\en"
406 - rctlblk_get_global_flags(rblk));
407 - (void) printf("Global actions: %x\en"
408 - rctlblk_get_global_action(rblk));
409 - (void) printf("Local flags: %x\en"
410 - rctlblk_get_local_flags(rblk));
411 - (void) printf("Local action: %x (%d)\en"
412 - raction, raction == RCTL_LOCAL_SIGNAL ? rsignal : 0);
413 - (void) printf("Value: %llu\en",
414 - rctlblk_get_value(rblk));
415 - (void) printf("\tEnforced value: %llu\en",
416 - rctlblk_get_enforced_value(rblk));
395 + raction = rctlblk_get_local_action(rblk, &rsignal),
396 + (void) printf("Resource control for %s\en",
397 + "process.max-cpu-time");
398 + (void) printf("Process ID: %d\en",
399 + (int)rctlblk_get_recipient_pid(rblk));
400 + (void) printf("Privilege: %x\en",
401 + rctlblk_get_privilege(rblk));
402 + (void) printf("Global flags: %x\en",
403 + rctlblk_get_global_flags(rblk));
404 + (void) printf("Global actions: %x\en",
405 + rctlblk_get_global_action(rblk));
406 + (void) printf("Local flags: %x\en",
407 + rctlblk_get_local_flags(rblk));
408 + (void) printf("Local action: %x (%d)\en",
409 + raction, raction == RCTL_LOCAL_SIGNAL ? rsignal : 0);
410 + (void) printf("Value: %llu\en",
411 + rctlblk_get_value(rblk));
412 + (void) printf("\tEnforced value: %llu\en",
413 + rctlblk_get_enforced_value(rblk));
414 +
415 + return (0);
417 416 }
418 417 .fi
419 418 .in -2
420 419
421 420 .SH ATTRIBUTES
422 -.sp
423 421 .LP
424 422 See \fBattributes\fR(5) for descriptions of the following attributes:
425 423 .sp
426 424
427 425 .sp
428 426 .TS
429 427 box;
430 428 c | c
431 429 l | l .
432 430 ATTRIBUTE TYPE ATTRIBUTE VALUE
433 431 _
434 432 Interface Stability Evolving
435 433 _
436 434 MT-Level MT-Safe
437 435 .TE
438 436
439 437 .SH SEE ALSO
440 -.sp
441 438 .LP
442 439 \fBrctladm\fR(1M), \fBgetrctl\fR(2), \fBsetrctl\fR(2), \fBgethrtime\fR(3C),
443 440 \fBattributes\fR(5)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX