contract_open, contract_latest, contract_abandon_id, getctid - common contract functions
cc [ flag... ] file... -D_LARGEFILE64_SOURCE -lcontract [ library... ] #include <libcontract.h> int contract_latest(cttype_t type, ctid_t *id) int contract_open(ctid_t ctid, cttype_t type, const char *file, int oflag) int contract_abandon_id(ctid_t ctid) ctid_t getctid()
These functions operate on contract control file descriptors obtained from the contract file system. For more information, see the contract(5) man page.
The contract_latest() function populates ctid_t with the contract ID of the latest contract created by the LWP of _type_. If the LWP has not created a _type_ contract, this function will return ESRCH. Acceptable values for _type_ are CT_TYPE_PROCESS or CT_TYPE_DEVICE.
The contract_open() function returns a file descriptor to the contract _file_ for the given _type_. For more information, see the STRUCTURE OF /system/contract/_type_/_id_ section in the contract(5) man page. The default flag for opening the file descriptor is O_CLOEXEC. The flag O_CREAT cannot be used. Acceptable values for _type_ are CT_TYPE_PROCESS, CT_TYPE_DEVICE, and CT_TYPE_ALL.
The contract_abandon_id() function abandons the contract _ctid_. It is a convenience wrapper on the ct_ctl_abandon() function. For more information, see the ct_ctl_abandon(3CONTRACT) man page.
The getctid() function returns the contract ID containing the current process.
Upon successful completion, the contract_latest() and contract_abandon_id() functions return 0, else, they return a non-zero error value. On error, the contract_open() and getctid() functions return -1 and set errno.
The contract_latest() function will fail if:
The type argument is not a valid.
No contract of _type_ has been created by the LWP.
The contract_open() function will fail if:
The file /system/contract/<type>/_id_/_file_ does not exist.
type, ID, and file arguments resulted in a ctfs name which is longer than PATH_MAX.
The contract_abandon_id() function will fail if:
No contract with id _ctid_ exists on the system.
The contract does not belong to the calling process.
The functions contract_latest(), contract_open(), contract_abandon_id(), and getctid() will fail if:
A signal was caught during an underlying open() or read() operation.
See attributes(7) for descriptions of the following attributes:
|
libcontract(3LIB), contract(5), ct_ctl_abandon(3CONTRACT), attributes(7), lfcompile(7)