PROCESS(5) | File Formats and Configurations | PROCESS(5) |
process - process contract type
/system/contract/process
Process contracts allow processes to create a fault boundary around a set of subprocesses and observe events which occur within that boundary.
Process contracts are managed using the contract(5) file system and the libcontract(3LIB) library. The process contract type directory is /system/contract/process.
A process contract is created when an LWP that has an active process contract template calls fork(2). Initially, the child process created by fork() is the only resource managed by the contract. When an LWP that does not have an active process contract template calls fork(), the child process created by fork() is added as a resource to the process contract of which the parent was a member.
The following events types are defined:
CT_PR_EV_EMPTY
CT_PR_EV_FORK
CT_PR_EV_EXIT
CT_PR_EV_CORE
CT_PR_EV_SIGNAL
CT_PR_EV_HWERR
The following common contract terms, defined in contract(5), have process-contract specific attributes:
critical event set
An attempt by a user without the {PRIV_CONTRACT_EVENT} privilege in its effective set to add an event, other than CT_PR_EV_EMPTY, to the critical event set which is not present in the fatal set, or if the CT_PR_PGONLY parameter is set and the same user attempts to add any event, other than CT_PR_EV_EMPTY, to the critical event set, fails.
informative event set
The following contract terms can be read from or written to a process contract template using the named libcontract(3LIB) interfaces. These contract terms are in addition to those described in contract(5).
creator's aux
fatal event set
The default value for the fatal event set is CT_PR_EV_HWERR.
If a user without the {PRIV_CONTRACT_EVENT} privilege in its effective set removes an event from the fatal event set which is present in the critical event set, the corresponding event is automatically removed from the critical event set and added to the informative event set.
parameter set
The default parameter set is empty.
The value is a bit vector comprised of some or all of:
CT_PR_INHERIT
If not set, the process contract is automatically abandoned when the owner exits.
CT_PR_KEEP_EXEC
CT_PR_NOORPHAN
If this is not set and the process contract is abandoned, the process contract is orphaned, that is, continues to exist without owner.
CT_PR_PGRPONLY
If not set, all processes within the process contract are killed if a member process encounters an error specified in the fatal set.
If a user without the {PRIV_CONTRACT_EVENT} privilege in its effective set adds CT_PR_PGRPONLY to a template's parameter set, any events other than CT_PR_EV_EMPTY are automatically removed from the critical event set and added to the informative event set.
CT_PR_REGENT
If not set, indicates that the process contract should not inherit contracts from member processes. If a process exits before abandoning a contract it owns and is a member of a process contract which does not have CT_PR_REGENT set, the system automatically abandons the contract.
If a regent process contract has inherited contracts and is abandoned by its owner, its inherited contracts are abandoned.
service FMRI
transfer contract
The default transfer term is 0, that is, no contract.
In addition to the standard items, the status object read from a status file descriptor contains the following items to obtain this information respectively:
service contract ID
ctid_t ctid; /* our contract id */ int fd; /* fd of ctid's status file */ ct_stathdl_(Bt status; ctid_t svc_ctid; if (ct_status_read(fd, CTD_FIXED, &status) == 0) {
if (ct_pr_status_get_svc_ctid(status, &svc_ctid) == 0) {
if (svc_ctid == ctid)
/* not inherited */
else
/* inherited */
}
ct_status_free(status); }
If CTD_ALL is specified, the following items are also available:
Member list
Inherited contract list
Service FMRI (term)
contract creator
creator's aux (term)
The following standard status items have different meanings in some situations:
Ownership state
Contract holder
In addition to the standard items, an event generated by a process contract contains the following information:
Generating PID
If the event type is CT_PR_EV_FORK, the event contains:
Parent PID
If the event type is CT_PR_EV_EXIT, the event contains:
Exit status
If the event type is CT_PR_EV_CORE, the event can contain:
Process core name
Global core name
Zone core name
See coreadm(8) for more information about per-process, global, and system-wide core files.
If the event type is CT_PR_EV_SIGNAL, the event contains:
Signal
It can contain:
sender
/usr/include/sys/contract/process.h
ctrun(1), ctstat(1), ctwatch(1), close(2), fork(2), ioctl(2), open(2), poll(2), ct_pr_event_get_exitstatus(3CONTRACT), ct_pr_event_get_gcorefile(3CONTRACT), ct_pr_event_get_pcorefile(3CONTRACT), ct_pr_event_get_pid(3CONTRACT), ct_pr_event_get_ppid(3CONTRACT), ct_pr_event_get_signal(3CONTRACT), ct_pr_event_get_zcorefile(3CONTRACT), ct_pr_status_get_contracts(3CONTRACT), ct_pr_status_get_members(3CONTRACT), ct_pr_status_get_param(3CONTRACT), ct_pr_tmpl_set_fatal(3CONTRACT), ct_pr_tmpl_set_param(3CONTRACT), ct_pr_tmpl_set_transfer(3CONTRACT), ct_tmpl_set_cookie(3CONTRACT), ct_tmpl_set_critical(3CONTRACT), ct_tmpl_set_informative(3CONTRACT), libcontract(3LIB), contract(5), privileges(7), coreadm(8)
December 28, 2020 | OmniOS |