2 .\" Copyright (c) 2008, 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 CTRUN 1 "Feb 25, 2008"
8 ctrun \- execute command in a process contract
12 \fB/usr/bin/ctrun\fR [\fIoptions\fR] \fIcommand\fR [ \fIargument\fR]...
18 The \fBctrun\fR utility starts a command in a newly created process contract.
19 \fBctrun\fR holds the contract and can be instructed to output or respond to
20 events that occur within the contract.
23 For additional information about process contracts, see \fBcontract\fR(4) and
28 The following options are supported:
32 \fB\fB-A\fR \fIfmri aux\fR\fR
35 Sets the process contract creator's auxiliary field.
41 \fB\fB-i\fR \fIevent\fR,[\fIevent\fR ...]\fR
45 \fB\fB-f\fR \fIevent\fR,[\fIevent\fR ...]\fR
48 Sets the informative and fatal events, respectively.
50 The following are valid \fIevent\fRs:
57 A member process dumped core.
59 \fBcore\fR events are informative by default.
68 The last member of the process contract exited.
77 A member process exited.
86 A process was added to the process contract.
95 A member process encountered a hardware error.
97 \fBhwerr\fR events are fatal by default.
106 A member process received a fatal signal from a process in a different process
110 Only \fBcore\fR, \fBhwerr\fR, and \fBsignal\fR events can be made fatal.
112 More events can be delivered than requested if \fBctrun\fR requires them for
113 its own purposes. For example, \fBempty\fR messages are always requested if a
114 lifetime of \fBcontract\fR is specified. See \fB-l\fR.
120 \fB\fB-F\fR \fIfmri\fR\fR
123 Sets the process contract service \fBFMRI\fR field. To set this field the
124 caller is required to have the \fB{PRIV_CONTRACT_IDENTITY}\fR in its effective
131 \fB\fB-l\fR \fIlifetime\fR\fR
134 The following valid \fIlifetime\fR values are supported:
141 \fBctrun\fR exits when the command exits, regardless of whether the contract is
151 \fBctrun\fR exits only when the contract exits. This is the default.
160 \fBctrun\fR exits immediately, orphaning the contract.
168 \fB\fB-o\fR \fIoption\fR,[\fIoption\fR ...]\fR
171 The following \fIoption\fRs are supported:
178 Kills all processes in the contract if the holder (\fBctrun\fR) exits.
180 This option is invalid when a lifetime of \fBnone\fR is specified.
189 If a fatal error occurs, kills at most the process group of which the errant
199 The contract inherits inheritable contracts when abandoned by member processes.
207 \fB\fB-r\fR \fIcount\fR\fR
210 If the contract encounters a fault, this option attempts to restart the command
211 \fIcount\fR times. If \fIcount\fR is \fB0\fR, the attempt to restart continues
212 indefinitely. By default, \fBctrun\fR does not attempt to restart the command.
214 This option is invalid if a lifetime other than \fBcontract\fR is specified or
215 if the \fBpgrponly\fR option is used.
224 If the contract created by \fBctrun\fR inherited subcontracts from its member
225 processes, attempts to transfer them to the new contract when restarting.
227 This option is invalid unless \fB-r\fR is also specified.
236 Displays contract events and \fBctrun\fR actions as they occur.
245 Displays verbose contract events, as are displayed by the \fB-v\fR option of
246 \fBctwatch\fR. Implies \fB-v\fR.
252 The following operands are supported:
259 One of the strings treated as an argument to \fIcommand\fR.
268 The command to be passed to \fBexecvp\fR(2). See \fBexec\fR(2).
273 \fBExample 1 \fRRunning a Shell in a New Process Contract
276 The following example runs a shell in a new process contract:
281 example% ctrun -l child -o pgrponly ksh
288 The \fB-l\fR \fBchild\fR option argument is specified so that \fBctrun\fR won't
289 wait until all children of the shell have exited. \fB-o\fR \fBpgrponly\fR is
290 specified because an interactive \fBksh\fR puts each job in a new process
291 group, and an error in one job is unlikely to affect the others.
294 \fBExample 2 \fRRunning a Simple Server
297 The following example runs a simple server:
302 example% \fBctrun -r 0 -t -f hwerr,core,signal server\fR
309 The \fB-r\fR \fB0\fR and \fB-t\fR options are specified to indicate that if the
310 server encounters a fatal error, \fBctrun\fR should try to restart it. The
311 \fB-f\fR option makes "\fBhwerr\fR", "\fBcore\fR", and "\fBsignal\fR" fatal
317 If \fIcommand\fR is specified and successfully invoked (see \fBexec\fR(2)), the
318 exit status of \fBctrun\fR is the exit status of \fIcommand\fR. Otherwise,
319 \fBctrun\fR exits with one of the following values:
326 The child process exited abnormally.
335 \fBctrun\fR encountered an internal error.
344 Invalid arguments were provided to \fBctrun\fR.
353 \fIcommand\fR was found but could not be invoked.
362 \fIcommand\fR could not be found.
369 \fB\fB/system/contract/process/*\fR\fR
378 See \fBattributes\fR(5) for descriptions of the following attributes:
386 ATTRIBUTE TYPE ATTRIBUTE VALUE
388 Interface Stability See below.
393 Human Readable Output is Uncommitted. Invocation is Committed.
397 \fBctstat\fR(1), \fBctwatch\fR(1), \fBexec\fR(2), \fBcontract\fR(4),
398 \fBprocess\fR(4), \fBattributes\fR(5)