Merge commit 'dc97a43d4a70c8773a619f11b95b07a787f6f5b7' into merges
[unleashed.git] / share / man / man3contract / ct_pr_event_get_pid.3contract
blobbdf1183ef17faa8296906ac0a4ecfe5929c3c640
1 '\" te
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"
7 .SH NAME
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
12 .SH SYNOPSIS
13 .LP
14 .nf
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);
20 .fi
22 .LP
23 .nf
24 \fBint\fR \fBct_pr_event_get_ppid\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBpid_t *\fR\fIpidp\fR);
25 .fi
27 .LP
28 .nf
29 \fBint\fR \fBct_pr_event_get_signal\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBint *\fR\fIsignalp\fR);
30 .fi
32 .LP
33 .nf
34 \fBint\fR \fBct_pr_event_get_sender\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBpid_t *\fR\fIpidp\fR);
35 .fi
37 .LP
38 .nf
39 \fBint\fR \fBct_pr_event_get_senderct\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBctid_t *\fR\fIpidp\fR);
40 .fi
42 .LP
43 .nf
44 \fBint\fR \fBct_pr_event_get_exitstatus\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBint *\fR\fIstatusp\fR);
45 .fi
47 .LP
48 .nf
49 \fBint\fR \fBct_pr_event_get_pcorefile\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBchar **\fR\fInamep\fR);
50 .fi
52 .LP
53 .nf
54 \fBint\fR \fBct_pr_event_get_gcorefile\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBchar **\fR\fInamep\fR);
55 .fi
57 .LP
58 .nf
59 \fBint\fR \fBct_pr_event_get_zcorefile\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBchar **\fR\fInamep\fR);
60 .fi
62 .SH DESCRIPTION
63 .sp
64 .LP
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).
68 .sp
69 .LP
70 The \fBct_pr_event_get_pid()\fR function reads the process ID of the process
71 generating the event.
72 .sp
73 .LP
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.
76 .sp
77 .LP
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.
80 .sp
81 .LP
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.
86 .sp
87 .LP
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
91 available only
92 .sp
93 .LP
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.
96 .sp
97 .LP
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
115 handle.
116 .SH RETURN VALUES
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.
125 .SH ERRORS
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:
134 .ne 2
136 \fB\fBEINVAL\fR\fR
138 .RS 10n
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:
150 .ne 2
152 \fB\fBEINVAL\fR\fR
154 .RS 10n
155 The requested data do not match the event type.
160 The \fBct_pr_event_get_sender()\fRa functions will fail if:
162 .ne 2
164 \fB\fBENOENT\fR\fR
166 .RS 10n
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:
176 .ne 2
178 \fB\fBENOENT\fR\fR
180 .RS 10n
181 The requested core file was not created.
186 The \fBct_pr_event_get_zcorefile()\fR function will fail if:
188 .ne 2
190 \fB\fBENOENT\fR\fR
192 .RS 10n
193 The event object was read by a process running in a non-global zone.
196 .SH EXAMPLES
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
203 encountered.
206 .in +2
208 #include <sys/types.h>
209 #include <fcntl.h>
210 #include <stdio.h>
211 #include <libcontract.h>
213 \&...
214 int fd;
215 ct_evthdl_t event;
216 pid_t pid, sender;
218 fd = open("/system/contract/process/bundle", O_RDONLY);
219 for (;;) {
220         ct_event_read(fd, &event);
221         if (ct_event_get_type(event) != CT_PR_EV_SIGNAL) {
222                 ct_event_free(event);
223                 continue;
224         }
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",
228                     (long)pid);
229         else
230                 printf("process %ld killed by process %ld\en",
231                     (long)pid, (long)sender);
232         ct_event_free(event);
234         ...
236 .in -2
238 .SH ATTRIBUTES
241 See \fBattributes\fR(5) for descriptions of the following attributes:
246 box;
247 c | c
248 l | l .
249 ATTRIBUTE TYPE  ATTRIBUTE VALUE
251 Interface Stability     Evolving
253 MT-Level        Safe
256 .SH SEE ALSO
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)