2 .\" Copyright (c) 2004, 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 CT_PR_EVENT_GET_PID 3CONTRACT "Jul 19, 2004"
8 ct_pr_event_get_pid, ct_pr_event_get_ppid, ct_pr_event_get_signal,
9 ct_pr_event_get_sender, ct_pr_event_get_senderct, ct_pr_event_get_exitstatus,
10 ct_pr_event_get_pcorefile, ct_pr_event_get_gcorefile, ct_pr_event_get_zcorefile
11 \- process contract event functions
15 cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-D_LARGEFILE64_SOURCE\fR \fB -lcontract \fR [ \fIlibrary\fR\&.\|.\|. ]
16 #include <libcontract.h>
17 #include <sys/contract/process.h>
19 \fBint\fR \fBct_pr_event_get_pid\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBpid_t *\fR\fIpidp\fR);
24 \fBint\fR \fBct_pr_event_get_ppid\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBpid_t *\fR\fIpidp\fR);
29 \fBint\fR \fBct_pr_event_get_signal\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBint *\fR\fIsignalp\fR);
34 \fBint\fR \fBct_pr_event_get_sender\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBpid_t *\fR\fIpidp\fR);
39 \fBint\fR \fBct_pr_event_get_senderct\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBctid_t *\fR\fIpidp\fR);
44 \fBint\fR \fBct_pr_event_get_exitstatus\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBint *\fR\fIstatusp\fR);
49 \fBint\fR \fBct_pr_event_get_pcorefile\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBchar **\fR\fInamep\fR);
54 \fBint\fR \fBct_pr_event_get_gcorefile\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBchar **\fR\fInamep\fR);
59 \fBint\fR \fBct_pr_event_get_zcorefile\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBchar **\fR\fInamep\fR);
65 These functions read process contract event information from an event object
66 returned by \fBct_event_read\fR(3CONTRACT) or
67 \fBct_event_read_critical\fR(3CONTRACT).
70 The \fBct_pr_event_get_pid()\fR function reads the process ID of the process
74 The \fBct_pr_event_get_ppid()\fR function reads the process ID of the process
75 that forked the new process causing the \fBCT_PR_EV_FORK\fR event.
78 The \fBct_pr_event_get_signal()\fR function reads the signal number of the
79 signal that caused the \fBCT_PR_EV_SIGNAL\fR event.
82 The \fBct_pr_event_get_sender()\fR function reads the process ID of the process
83 that sent the signal that caused the \fBCT_PR_EV_SIGNAL\fR event. If the
84 signal's sender was not in the same zone as the signal's recipient, this
85 information is available only to event consumers in the global zone.
88 The ct_pr_event_get_senderct function reads the contract ID of the process that
89 sent the signal that caused the CT_PR_EV_SIGNAL event. If the signal's sender
90 was not in the same zone as the signal's recipient, this information is
94 The \fBct_pr_event_get_exitstatus()\fR function reads the exit status of the
95 process generating a \fBCT_PR_EV_EXIT\fR event.
98 The \fBct_pr_event_get_pcorefile()\fR function reads the name of the process
99 core file if one was created when the \fBCT_PR_EV_CORE\fR event was generated.
100 A pointer to a character array is stored in *\fInamep\fR and is freed when
101 \fBct_event_free\fR(3CONTRACT) is called on the event handle.
104 The \fBct_pr_event_get_gcorefile()\fR function reads the name of the zone's
105 global core file if one was created when the \fBCT_PR_EV_CORE\fR event was
106 generated. A pointer to a character array is stored in *\fInamep\fR and is
107 freed when \fBct_event_free()\fR is called on the event handle.
110 The \fBct_pr_event_get_zcorefile()\fR function reads the name of the
111 system-wide core file in the global zone if one was created when the
112 \fBCT_PR_EV_CORE\fR event was generated. This information is available only to
113 event consumers in the global zone. A pointer to a character array is stored in
114 *\fInamep\fR and is freed when \fBct_event_free()\fR is called on the event
119 Upon successful completion, \fBct_pr_event_get_pid()\fR,
120 \fBct_pr_event_get_ppid()\fR, \fBct_pr_event_get_signal()\fR,
121 \fBct_pr_event_get_sender()\fR, \fBct_pr_event_get_senderct()\fR,
122 \fBct_pr_event_get_exitstatus()\fR, \fBct_pr_event_get_pcorefile()\fR,
123 \fBct_pr_event_get_gcorefile()\fR, and \fBct_pr_event_get_zcorefile()\fR return
124 0. Otherwise, they return a non-zero error value.
128 The \fBct_pr_event_get_pid()\fR, \fBct_pr_event_get_ppid()\fR,
129 \fBct_pr_event_get_signal()\fR, \fBct_pr_event_get_sender()\fR,
130 \fBct_pr_event_get_senderct()\fR, \fBct_pr_event_get_exitstatus()\fR,
131 \fBct_pr_event_get_pcorefile()\fR, \fBct_pr_event_get_gcorefile()\fR, and
132 \fBct_pr_event_get_zcorefile()\fR functions will fail if:
139 The \fIevthdl\fR argument is not a process contract event object.
144 The \fBct_pr_event_get_ppid()\fR, \fBct_pr_event_get_signal()\fR,
145 \fBct_pr_event_get_sender()\fR, \fBct_pr_event_get_senderct()\fR,
146 \fBct_pr_event_get_exitstatus()\fR, \fBct_pr_event_get_pcorefile()\fR,
147 \fBct_pr_event_get_gcorefile()\fR, and \fBct_pr_event_get_zcorefile()\fR
148 functions will fail if:
155 The requested data do not match the event type.
160 The \fBct_pr_event_get_sender()\fRa functions will fail if:
167 The process ID of the sender was not available, or the event object was read by
168 a process running in a non-global zone and the sender was in a different zone.
173 The \fBct_pr_event_get_pcorefile()\fR, \fBct_pr_event_get_gcorefile()\fR, and
174 \fBct_pr_event_get_zcorefile()\fR functions will fail if:
181 The requested core file was not created.
186 The \fBct_pr_event_get_zcorefile()\fR function will fail if:
193 The event object was read by a process running in a non-global zone.
198 \fBExample 1 \fRPrint the instigator of all \fBCT_PR_EV_SIGNAL\fR events.
201 Open the process contract bundle. Loop reading events. Fetch and display the
202 signalled pid and signalling pid for each \fBCT_PR_EV_SIGNAL\fR event
208 #include <sys/types.h>
211 #include <libcontract.h>
218 fd = open("/system/contract/process/bundle", O_RDONLY);
220 ct_event_read(fd, &event);
221 if (ct_event_get_type(event) != CT_PR_EV_SIGNAL) {
222 ct_event_free(event);
225 ct_pr_event_get_pid(event, &pid);
226 if (ct_pr_event_get_sender(event, &sender) == ENOENT)
227 printf("process %ld killed by unknown process\en",
230 printf("process %ld killed by process %ld\en",
231 (long)pid, (long)sender);
232 ct_event_free(event);
241 See \fBattributes\fR(5) for descriptions of the following attributes:
249 ATTRIBUTE TYPE ATTRIBUTE VALUE
251 Interface Stability Evolving
259 \fBct_event_free\fR(3CONTRACT), \fBct_event_read\fR(3CONTRACT),
260 \fBct_event_read_critical\fR(3CONTRACT), \fBlibcontract\fR(3LIB),
261 \fBcontract\fR(4), \fBprocess\fR(4), \fBattributes\fR(5), \fBlfcompile\fR(5)