Contract Management Library Functions
ct_pr_event_get_pid(3CONTRACT)
NAME
ct_pr_event_get_pid, ct_pr_event_get_ppid,
ct_pr_event_get_signal, ct_pr_event_get_sender,
ct_pr_event_get_senderct, ct_pr_event_get_exitstatus,
ct_pr_event_get_pcorefile, ct_pr_event_get_gcorefile,
ct_pr_event_get_zcorefile - process contract event functions
SYNOPSIS
cc [ flag... ] file... -D_LARGEFILE64_SOURCE -lcontract [ library... ]
#include
#include
int ct_pr_event_get_pid(ct_evthdl_t evthdl, pid_t *pidp);
int ct_pr_event_get_ppid(ct_evthdl_t evthdl, pid_t *pidp);
int ct_pr_event_get_signal(ct_evthdl_t evthdl, int *signalp);
int ct_pr_event_get_sender(ct_evthdl_t evthdl, pid_t *pidp);
int ct_pr_event_get_senderct(ct_evthdl_t evthdl, ctid_t *pidp);
int ct_pr_event_get_exitstatus(ct_evthdl_t evthdl, int *statusp);
int ct_pr_event_get_pcorefile(ct_evthdl_t evthdl, char **namep);
int ct_pr_event_get_gcorefile(ct_evthdl_t evthdl, char **namep);
int ct_pr_event_get_zcorefile(ct_evthdl_t evthdl, char **namep);
DESCRIPTION
These functions read process contract event information froman event object returned by ct_event_read(3CONTRACT) or
ct_event_read_critical(3CONTRACT).
The ct_pr_event_get_pid() function reads the process ID of
the process generating the event.The ct_pr_event_get_ppid() function reads the process ID of
the process that forked the new process causing theSunOS 5.11 Last change: 19 Jul 2004 1
Contract Management Library Functionsct_pr_event_get_pid(3CONTRACT)
CT_PR_EV_FORK event.
The ct_pr_event_get_signal() function reads the signal
number of the signal that caused the CT_PR_EV_SIGNAL event.
The ct_pr_event_get_sender() function reads the process ID
of the process that sent the signal that caused theCT_PR_EV_SIGNAL event. If the signal's sender was not in the
same zone as the signal's recipient, this information is available only to event consumers in the global zone.The ct_pr_event_get_senderct function reads the contract ID
of the process that sent the signal that caused theCT_PR_EV_SIGNAL event. If the signal's sender was not in the
same zone as the signal's recipient, this information is available onlyThe ct_pr_event_get_exitstatus() function reads the exit
status of the process generating a CT_PR_EV_EXIT event.
The ct_pr_event_get_pcorefile() function reads the name of
the process core file if one was created when theCT_PR_EV_CORE event was generated. A pointer to a character
array is stored in *namep and is freed whenct_event_free(3CONTRACT) is called on the event handle.
The ct_pr_event_get_gcorefile() function reads the name of
the zone's global core file if one was created when theCT_PR_EV_CORE event was generated. A pointer to a character
array is stored in *namep and is freed when ct_event_free()
is called on the event handle.The ct_pr_event_get_zcorefile() function reads the name of
the system-wide core file in the global zone if one was
created when the CT_PR_EV_CORE event was generated. This
information is available only to event consumers in the glo-
bal zone. A pointer to a character array is stored in *namepand is freed when ct_event_free() is called on the event
handle.RETURN VALUES
Upon successful completion, ct_pr_event_get_pid(),
ct_pr_event_get_ppid(), ct_pr_event_get_signal(),
ct_pr_event_get_sender(), ct_pr_event_get_senderct(),
SunOS 5.11 Last change: 19 Jul 2004 2
Contract Management Library Functionsct_pr_event_get_pid(3CONTRACT)
ct_pr_event_get_exitstatus(), ct_pr_event_get_pcorefile(),
ct_pr_event_get_gcorefile(), and ct_pr_event_get_zcorefile()
return 0. Otherwise, they return a non-zero error value.
ERRORS
The ct_pr_event_get_pid(), ct_pr_event_get_ppid(),
ct_pr_event_get_signal(), ct_pr_event_get_sender(),
ct_pr_event_get_senderct(), ct_pr_event_get_exitstatus(),
ct_pr_event_get_pcorefile(), ct_pr_event_get_gcorefile(),
and ct_pr_event_get_zcorefile() functions will fail if:
EINVAL The evthdl argument is not a process contract event object.The ct_pr_event_get_ppid(), ct_pr_event_get_signal(),
ct_pr_event_get_sender(), ct_pr_event_get_senderct(),
ct_pr_event_get_exitstatus(), ct_pr_event_get_pcorefile(),
ct_pr_event_get_gcorefile(), and ct_pr_event_get_zcorefile()
functions will fail if: EINVAL The requested data do not match the event type.The ct_pr_event_get_sender()a functions will fail if:
ENOENT The process ID of the sender was not available, or the event object was read by a process running ina non-global zone and the sender was in a dif-
ferent zone.The ct_pr_event_get_pcorefile(),
ct_pr_event_get_gcorefile(), and ct_pr_event_get_zcorefile()
functions will fail if: ENOENT The requested core file was not created.The ct_pr_event_get_zcorefile() function will fail if:
ENOENT The event object was read by a process running ina non-global zone.
EXAMPLES
SunOS 5.11 Last change: 19 Jul 2004 3
Contract Management Library Functionsct_pr_event_get_pid(3CONTRACT)
Example 1 Print the instigator of all CT_PR_EV_SIGNAL
events. Open the process contract bundle. Loop reading events. Fetch and display the signalled pid and signalling pid for eachCT_PR_EV_SIGNAL event encountered.
#include
#include
#include
#include
... int fd;ct_evthdl_t event;
pid_t pid, sender;
fd = open("/system/contract/process/bundle", O_RDONLY);
for (;;) {ct_event_read(fd, &event);
if (ct_event_get_type(event) != CT_PR_EV_SIGNAL) {
ct_event_free(event);
continue; }ct_pr_event_get_pid(event, &pid);
if (ct_pr_event_get_sender(event, &sender) == ENOENT)
printf("process %ld killed by unknown process\n",
(long)pid); elseprintf("process %ld killed by process %ld\n",
(long)pid, (long)sender);ct_event_free(event);
} ...ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:SunOS 5.11 Last change: 19 Jul 2004 4
Contract Management Library Functionsct_pr_event_get_pid(3CONTRACT)
______________________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| Interface Stability | Committed ||_____________________________|_____________________________|
| MT-Level | Safe |
|_____________________________|_____________________________|
SEE ALSO
ct_event_free(3CONTRACT), ct_event_read(3CONTRACT),
ct_event_read_critical(3CONTRACT), libcontract(3LIB), con-
tract(4), process(4), attributes(5), lfcompile(5)SunOS 5.11 Last change: 19 Jul 2004 5
Contract Management Library Functionsct_pr_event_get_pid(3CONTRACT)
SunOS 5.11 Last change: 19 Jul 2004 6