Merge commit 'b31ca922c7346747131aed07c0c171ec2f573aac' into merges
[unleashed.git] / share / man / man3project / setproject.3project
blob567c01f6a9ebebd52ebd538016fb706a13897640
1 '\" te
2 .\" Copyright (c) 2007, 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.
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 .\" 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 SETPROJECT 3PROJECT "Apr 10, 2007"
7 .SH NAME
8 setproject \- associate a user process with a project
9 .SH SYNOPSIS
10 .LP
11 .nf
12 cc [ \fIflag \&.\|.\|.\fR ] \fIfile\fR\&.\|.\|. \fB-lproject\fR [ \fIlibrary \&.\|.\|.\fR ]
13 #include <project.h>
15 \fBint\fR \fBsetproject\fR(\fBconst char *\fR\fIproject_name\fR, \fBconst char *\fR\fIuser_name\fR,
16      \fBuint_t\fR \fIflags\fR);
17 .fi
19 .SH DESCRIPTION
20 .sp
21 .LP
22 The \fBsetproject()\fR function provides a simplified method for the
23 association of a user process with a project and its various resource
24 management attributes, as stored in the \fBproject\fR(4) name service database.
25 These attributes include resource control settings, resource pool membership,
26 and third party attributes (which are ignored by \fBsetproject()\fR.)
27 .sp
28 .LP
29 If \fIuser_name\fR is a valid member of the project specified by
30 \fIproject_name\fR, as determined by \fBinproj\fR(3PROJECT), \fBsetproject()\fR
31 will create a new task with \fBsettaskid\fR(2) using task flags specified by
32 \fIflags\fR, use \fBsetrctl\fR(2) to associate various resource controls with
33 the process, task, and project, and bind the calling process to the appropriate
34 resource pool with \fBpool_set_binding\fR(3POOL).  Resource controls not
35 explicitly specified in the project entry will be preserved. If \fIuser_name\fR
36 is a name of the superuser (user with UID equal to 0), the \fBsetproject()\fR
37 function skips the \fBinproj\fR(3PROJECT) check described above and allows the
38 superuser to join any project.
39 .sp
40 .LP
41 The current process will not be bound to a resource pool if the resource pools
42 facility (see \fBpooladm\fR(8)) is inactive. The \fBsetproject()\fR function
43 will succeed whether or not the project specified by \fIproject_name\fR
44 specifies a \fBproject.pool\fR attribute. If the resource pools facility is
45 active, \fBsetproject()\fR will fail if the project does not specify a
46 \fBproject.pool\fR attribute and there is no designated pool accepting default
47 assignments. The \fBsetproject()\fR function will also fail if there is a
48 specified \fBproject.pool\fR attribute for a nonexistent pool.
49 .SH RETURN VALUES
50 .sp
51 .LP
52 Upon successful completion, \fBsetproject()\fR returns 0. If any of the
53 resource control assignments failed but the project assignment, pool binding,
54 and task creation succeeded, an integer value corresponding to the offset into
55 the key-value pair list of the failed attribute assignment is returned. If the
56 project assignment or task creation was not successful, \fBsetproject()\fR
57 returns \fBSETPROJ_ERR_TASK\fR and sets \fBerrno\fR to indicate the error. In
58 the event of a pool binding failure, \fBsetproject()\fR returns
59 \fBSETPROJ_ERR_POOL\fR and sets \fBerrno\fR to indicate the error. Additional
60 error information can be retrieved from \fBpool_error\fR(3POOL).
61 .SH ERRORS
62 .sp
63 .LP
64 The \fBsetproject()\fR function will fail during project assignment or task
65 creation if:
66 .sp
67 .ne 2
68 .na
69 \fB\fBEACCES\fR\fR
70 .ad
71 .RS 10n
72 The invoking task was created with the \fBTASK_FINAL\fR flag.
73 .RE
75 .sp
76 .ne 2
77 .na
78 \fB\fBEAGAIN\fR\fR
79 .ad
80 .RS 10n
81 A resource control limiting the number of LWPs or tasks in the target project
82 or zone has been exceeded.
83 .sp
84 A resource control on the given project would be exceeded.
85 .RE
87 .sp
88 .ne 2
89 .na
90 \fB\fBEINVAL\fR\fR
91 .ad
92 .RS 10n
93 The project ID associated with the given project is not within the range of
94 valid project IDs, invalid flags were specified, or \fIuser_name\fR is
95 \fINULL\fR.
96 .RE
98 .sp
99 .ne 2
101 \fB\fBEPERM\fR\fR
103 .RS 10n
104 The effective user of the calling process is not superuser.
108 .ne 2
110 \fB\fBESRCH\fR\fR
112 .RS 10n
113 The specified user is not a valid user of the given project, \fIuser_name\fR is
114 not valid user name, or \fIproject_name\fR is not valid project name.
119 The \fBsetproject()\fR function will fail during pool binding if:
121 .ne 2
123 \fB\fBEACCES\fR\fR
125 .RS 10n
126 No resource pool accepting default bindings exists.
130 .ne 2
132 \fB\fBEPERM\fR\fR
134 .RS 10n
135 The effective user of the calling process is not superuser.
139 .ne 2
141 \fB\fBESRCH\fR\fR
143 .RS 10n
144 The specified resource pool is unknown
149 If \fBsetproject()\fR returns an offset into the key-value pair list, the
150 returned error value is associated with \fBsetrctl\fR(2) for resource control
151 attributes.
152 .SH USAGE
155 The \fBsetproject()\fR function recognizes a name-structured value pair for the
156 attributes in the \fBproject\fR(4) database with the following format:
158 .in +2
160 entity.control=(\fIprivilege\fR,\fIvalue\fR,\fIaction\fR,\fIaction\fR,\&.\|.\|.),\&.\|.\|.
162 .in -2
166 where \fIprivilege\fR is one of \fBBASIC\fR or \fBPRIVILEGED\fR, \fIvalue\fR is
167 a numeric value with optional units, and \fIaction\fR is one of \fBnone\fR,
168 \fBdeny\fR, and \fBsignal\fR=\fIsignum\fR or \fBsignal\fR=\fISIGNAME\fR. For
169 instance, to set a series of progressively more assertive control values on a
170 project's per-process CPU time, specify
172 .in +2
174 process.max-cpu-time=(PRIVILEGED,1000s,signal=SIGXRES), \e
175 (PRIVILEGED,1250, signal=SIGTERM),(PRIVILEGED,1500,
176      signal=SIGKILL)
178 .in -2
182 To prevent a task from exceeding a total of 128 LWPs, specify a resource
183 control with
185 .in +2
187 task.max-lwps=(PRIVILEGED,128,deny)
189 .in -2
193 Specifying a resource control name with no values causes all resource control
194 values for that name to be cleared on the given project, leaving only the
195 system resource control value on the specified resource control name.
198 For example, to remove all resource control values on shared memory, specify:
200 .in +2
202 project.max-shm-memory
204 .in -2
208 The project attribute, \fBproject.pool\fR, specifies the pool to which
209 processes associated with the project entry should be bound. Its format is:
211 .in +2
213 project.pool=pool_name
215 .in -2
219 where \fBpool_name\fR is a valid resource pool within the active configuration
220 enabled with \fBpooladm\fR(8).
223 The final attribute is used to finalize the task created by \fBsetproject()\fR.
224 See \fBsettaskid\fR(2).
226 .in +2
228 task.final
230 .in -2
234 All further attempts to create new tasks, such as using \fBnewtask\fR(1) and
235 \fBsu\fR(8), will fail.
236 .SH ATTRIBUTES
239 See \fBattributes\fR(5) for descriptions of the following attributes:
244 box;
245 c | c
246 l | l .
247 ATTRIBUTE TYPE  ATTRIBUTE VALUE
249 Interface Stability     Evolving
251 MT-Level        MT-Safe
254 .SH SEE ALSO
257 \fBpooladm\fR(8), \fBsetrctl\fR(2), \fBsettaskid\fR(2),
258 \fBinproj\fR(3PROJECT), \fBlibproject\fR(3LIB), \fBpool_error\fR(3POOL),
259 \fBpool_set_binding\fR(3POOL), \fBpasswd\fR(4), \fBproject\fR(4),
260 \fBattributes\fR(5)