1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
'\" te
.\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright 2021 Peter Tribble.
.\" 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.
.\" 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.
.\" 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]
.TH CT_PR_EVENT_GET_PID 3CONTRACT "November 21, 2021"
.SH 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
.SH SYNOPSIS
.nf
cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-D_LARGEFILE64_SOURCE\fR \fB -lcontract \fR [ \fIlibrary\fR\&.\|.\|. ]
#include <libcontract.h>
#include <sys/contract/process.h>
\fBint\fR \fBct_pr_event_get_pid\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBpid_t *\fR\fIpidp\fR);
.fi
.LP
.nf
\fBint\fR \fBct_pr_event_get_ppid\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBpid_t *\fR\fIpidp\fR);
.fi
.LP
.nf
\fBint\fR \fBct_pr_event_get_signal\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBint *\fR\fIsignalp\fR);
.fi
.LP
.nf
\fBint\fR \fBct_pr_event_get_sender\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBpid_t *\fR\fIpidp\fR);
.fi
.LP
.nf
\fBint\fR \fBct_pr_event_get_senderct\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBctid_t *\fR\fIctidp\fR);
.fi
.LP
.nf
\fBint\fR \fBct_pr_event_get_exitstatus\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBint *\fR\fIstatusp\fR);
.fi
.LP
.nf
\fBint\fR \fBct_pr_event_get_pcorefile\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBchar **\fR\fInamep\fR);
.fi
.LP
.nf
\fBint\fR \fBct_pr_event_get_gcorefile\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBchar **\fR\fInamep\fR);
.fi
.LP
.nf
\fBint\fR \fBct_pr_event_get_zcorefile\fR(\fBct_evthdl_t\fR \fIevthdl\fR, \fBchar **\fR\fInamep\fR);
.fi
.SH DESCRIPTION
These functions read process contract event information from an event object
returned by \fBct_event_read\fR(3CONTRACT) or
\fBct_event_read_critical\fR(3CONTRACT).
.sp
.LP
The \fBct_pr_event_get_pid()\fR function reads the process ID of the process
generating the event.
.sp
.LP
The \fBct_pr_event_get_ppid()\fR function reads the process ID of the process
that forked the new process causing the \fBCT_PR_EV_FORK\fR event.
.sp
.LP
The \fBct_pr_event_get_signal()\fR function reads the signal number of the
signal that caused the \fBCT_PR_EV_SIGNAL\fR event.
.sp
.LP
The \fBct_pr_event_get_sender()\fR function reads the process ID of the process
that sent the signal that caused the \fBCT_PR_EV_SIGNAL\fR 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.
.sp
.LP
The \fBct_pr_event_get_senderct()\fR function reads the contract ID of the
process that sent the signal that caused the \fBCT_PR_EV_SIGNAL\fR 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.
.sp
.LP
The \fBct_pr_event_get_exitstatus()\fR function reads the exit status of the
process generating a \fBCT_PR_EV_EXIT\fR event.
.sp
.LP
The \fBct_pr_event_get_pcorefile()\fR function reads the name of the process
core file if one was created when the \fBCT_PR_EV_CORE\fR event was generated.
A pointer to a character array is stored in *\fInamep\fR and is freed when
\fBct_event_free\fR(3CONTRACT) is called on the event handle.
.sp
.LP
The \fBct_pr_event_get_gcorefile()\fR function reads the name of the zone's
global core file if one was created when the \fBCT_PR_EV_CORE\fR event was
generated. A pointer to a character array is stored in *\fInamep\fR and is
freed when \fBct_event_free()\fR is called on the event handle.
.sp
.LP
The \fBct_pr_event_get_zcorefile()\fR function reads the name of the
system-wide core file in the global zone if one was created when the
\fBCT_PR_EV_CORE\fR event was generated. This information is available only to
event consumers in the global zone. A pointer to a character array is stored in
*\fInamep\fR and is freed when \fBct_event_free()\fR is called on the event
handle.
.SH RETURN VALUES
Upon successful completion, \fBct_pr_event_get_pid()\fR,
\fBct_pr_event_get_ppid()\fR, \fBct_pr_event_get_signal()\fR,
\fBct_pr_event_get_sender()\fR, \fBct_pr_event_get_senderct()\fR,
\fBct_pr_event_get_exitstatus()\fR, \fBct_pr_event_get_pcorefile()\fR,
\fBct_pr_event_get_gcorefile()\fR, and \fBct_pr_event_get_zcorefile()\fR return
0. Otherwise, they return a non-zero error value.
.SH ERRORS
The \fBct_pr_event_get_pid()\fR, \fBct_pr_event_get_ppid()\fR,
\fBct_pr_event_get_signal()\fR, \fBct_pr_event_get_sender()\fR,
\fBct_pr_event_get_senderct()\fR, \fBct_pr_event_get_exitstatus()\fR,
\fBct_pr_event_get_pcorefile()\fR, \fBct_pr_event_get_gcorefile()\fR, and
\fBct_pr_event_get_zcorefile()\fR functions will fail if:
.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
The \fIevthdl\fR argument is not a process contract event object.
.RE
.sp
.LP
The \fBct_pr_event_get_ppid()\fR, \fBct_pr_event_get_signal()\fR,
\fBct_pr_event_get_sender()\fR, \fBct_pr_event_get_senderct()\fR,
\fBct_pr_event_get_exitstatus()\fR, \fBct_pr_event_get_pcorefile()\fR,
\fBct_pr_event_get_gcorefile()\fR, and \fBct_pr_event_get_zcorefile()\fR
functions will fail if:
.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
The requested data do not match the event type.
.RE
.sp
.LP
The \fBct_pr_event_get_sender()\fR and \fBct_pr_event_get_senderct()\fR
functions will fail if:
.sp
.ne 2
.na
\fB\fBENOENT\fR\fR
.ad
.RS 10n
The process or contract ID of the sender was not available, or the event object
was read by a process running in a non-global zone and the sender was in a
different zone.
.RE
.sp
.LP
The \fBct_pr_event_get_pcorefile()\fR, \fBct_pr_event_get_gcorefile()\fR, and
\fBct_pr_event_get_zcorefile()\fR functions will fail if:
.sp
.ne 2
.na
\fB\fBENOENT\fR\fR
.ad
.RS 10n
The requested core file was not created.
.RE
.sp
.LP
The \fBct_pr_event_get_zcorefile()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBENOENT\fR\fR
.ad
.RS 10n
The event object was read by a process running in a non-global zone.
.RE
.SH EXAMPLES
\fBExample 1 \fRPrint the instigator of all \fBCT_PR_EV_SIGNAL\fR events.
.sp
.LP
Open the process contract bundle. Loop reading events. Fetch and display the
signalled pid and signalling pid for each \fBCT_PR_EV_SIGNAL\fR event
encountered.
.sp
.in +2
.nf
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <libcontract.h>
\&...
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\en",
(long)pid);
else
printf("process %ld killed by process %ld\en",
(long)pid, (long)sender);
ct_event_free(event);
}
...
.fi
.in -2
.SH ATTRIBUTES
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Evolving
_
MT-Level Safe
.TE
.SH SEE ALSO
.BR ct_event_free (3CONTRACT),
.BR ct_event_read (3CONTRACT),
.BR ct_event_read_critical (3CONTRACT),
.BR libcontract (3LIB),
.BR contract (5),
.BR process (5),
.BR attributes (7),
.BR lfcompile (7)
|