1ct_pr_event_get_pid(3CCOoNnTtRrAaCcTt)Management LibrarycFtu_npcrt_ieovnesnt_get_pid(3CONTRACT)
2
3
4

NAME

6       ct_pr_event_get_pid,    ct_pr_event_get_ppid,   ct_pr_event_get_signal,
7       ct_pr_event_get_sender, ct_pr_event_get_senderct, ct_pr_event_get_exit‐
8       status,      ct_pr_event_get_pcorefile,      ct_pr_event_get_gcorefile,
9       ct_pr_event_get_zcorefile - process contract event functions
10

SYNOPSIS

12       cc [ flag... ] file... -D_LARGEFILE64_SOURCE  -lcontract  [ library... ]
13       #include <libcontract.h>
14       #include <sys/contract/process.h>
15
16       int ct_pr_event_get_pid(ct_evthdl_t evthdl, pid_t *pidp);
17
18
19       int ct_pr_event_get_ppid(ct_evthdl_t evthdl, pid_t *pidp);
20
21
22       int ct_pr_event_get_signal(ct_evthdl_t evthdl, int *signalp);
23
24
25       int ct_pr_event_get_sender(ct_evthdl_t evthdl, pid_t *pidp);
26
27
28       int ct_pr_event_get_senderct(ct_evthdl_t evthdl, ctid_t *pidp);
29
30
31       int ct_pr_event_get_exitstatus(ct_evthdl_t evthdl, int *statusp);
32
33
34       int ct_pr_event_get_pcorefile(ct_evthdl_t evthdl, char **namep);
35
36
37       int ct_pr_event_get_gcorefile(ct_evthdl_t evthdl, char **namep);
38
39
40       int ct_pr_event_get_zcorefile(ct_evthdl_t evthdl, char **namep);
41
42

DESCRIPTION

44       These functions read process contract event information from  an  event
45       object  returned  by  ct_event_read(3CONTRACT)  or ct_event_read_criti‐
46       cal(3CONTRACT).
47
48
49       The ct_pr_event_get_pid() function reads the process ID of the  process
50       generating the event.
51
52
53       The ct_pr_event_get_ppid() function reads the process ID of the process
54       that forked the new process causing the CT_PR_EV_FORK event.
55
56
57       The ct_pr_event_get_signal() function reads the signal  number  of  the
58       signal that caused the CT_PR_EV_SIGNAL event.
59
60
61       The  ct_pr_event_get_sender()  function  reads  the  process  ID of the
62       process that sent the signal that caused the CT_PR_EV_SIGNAL event.  If
63       the signal's sender was not in the same zone as the signal's recipient,
64       this information is available only to event  consumers  in  the  global
65       zone.
66
67
68       The  ct_pr_event_get_senderct  function  reads  the  contract ID of the
69       process that sent the signal that caused the CT_PR_EV_SIGNAL event.  If
70       the signal's sender was not in the same zone as the signal's recipient,
71       this information is available only
72
73
74       The ct_pr_event_get_exitstatus() function reads the exit status of  the
75       process generating a CT_PR_EV_EXIT event.
76
77
78       The  ct_pr_event_get_pcorefile() function reads the name of the process
79       core file if one was created when the CT_PR_EV_CORE  event  was  gener‐
80       ated.  A  pointer to a character array is stored in *namep and is freed
81       when ct_event_free(3CONTRACT) is called on the event handle.
82
83
84       The ct_pr_event_get_gcorefile() function reads the name of  the  zone's
85       global  core  file  if one was created when the CT_PR_EV_CORE event was
86       generated. A pointer to a character array is stored in  *namep  and  is
87       freed when ct_event_free() is called on the event handle.
88
89
90       The  ct_pr_event_get_zcorefile() function reads the name of the system-
91       wide core file  in  the  global  zone  if  one  was  created  when  the
92       CT_PR_EV_CORE  event  was generated. This information is available only
93       to event consumers in the global zone. A pointer to a  character  array
94       is  stored in *namep and is freed when ct_event_free() is called on the
95       event handle.
96

RETURN VALUES

98       Upon        successful        completion,        ct_pr_event_get_pid(),
99       ct_pr_event_get_ppid(),                       ct_pr_event_get_signal(),
100       ct_pr_event_get_sender(),                   ct_pr_event_get_senderct(),
101       ct_pr_event_get_exitstatus(),              ct_pr_event_get_pcorefile(),
102       ct_pr_event_get_gcorefile(), and ct_pr_event_get_zcorefile() return  0.
103       Otherwise, they return a non-zero error value.
104

ERRORS

106       The ct_pr_event_get_pid(), ct_pr_event_get_ppid(), ct_pr_event_get_sig‐
107       nal(),      ct_pr_event_get_sender(),       ct_pr_event_get_senderct(),
108       ct_pr_event_get_exitstatus(),              ct_pr_event_get_pcorefile(),
109       ct_pr_event_get_gcorefile(), and ct_pr_event_get_zcorefile()  functions
110       will fail if:
111
112       EINVAL    The evthdl argument is not a process contract event object.
113
114
115
116       The          ct_pr_event_get_ppid(),          ct_pr_event_get_signal(),
117       ct_pr_event_get_sender(),                   ct_pr_event_get_senderct(),
118       ct_pr_event_get_exitstatus(),              ct_pr_event_get_pcorefile(),
119       ct_pr_event_get_gcorefile(), and ct_pr_event_get_zcorefile()  functions
120       will fail if:
121
122       EINVAL    The requested data do not match the event type.
123
124
125
126       The ct_pr_event_get_sender()a functions will fail if:
127
128       ENOENT    The  process ID of the sender was not available, or the event
129                 object was read by a process running in a non-global zone and
130                 the sender was in a different zone.
131
132
133
134       The   ct_pr_event_get_pcorefile(),   ct_pr_event_get_gcorefile(),   and
135       ct_pr_event_get_zcorefile() functions will fail if:
136
137       ENOENT    The requested core file was not created.
138
139
140
141       The ct_pr_event_get_zcorefile() function will fail if:
142
143       ENOENT    The event object was read by a  process  running  in  a  non-
144                 global zone.
145
146

EXAMPLES

148       Example 1 Print the instigator of all CT_PR_EV_SIGNAL events.
149
150
151       Open  the  process contract bundle. Loop reading events. Fetch and dis‐
152       play the signalled pid and  signalling  pid  for  each  CT_PR_EV_SIGNAL
153       event encountered.
154
155
156         #include <sys/types.h>
157         #include <fcntl.h>
158         #include <stdio.h>
159         #include <libcontract.h>
160
161         ...
162         int fd;
163         ct_evthdl_t event;
164         pid_t pid, sender;
165
166         fd = open("/system/contract/process/bundle", O_RDONLY);
167         for (;;) {
168                 ct_event_read(fd, &event);
169                 if (ct_event_get_type(event) != CT_PR_EV_SIGNAL) {
170                         ct_event_free(event);
171                         continue;
172                 }
173                 ct_pr_event_get_pid(event, &pid);
174                 if (ct_pr_event_get_sender(event, &sender) == ENOENT)
175                         printf("process %ld killed by unknown process\n",
176                             (long)pid);
177                 else
178                         printf("process %ld killed by process %ld\n",
179                             (long)pid, (long)sender);
180                 ct_event_free(event);
181         }
182                 ...
183
184

ATTRIBUTES

186       See attributes(5) for descriptions of the following attributes:
187
188
189
190
191       ┌─────────────────────────────┬─────────────────────────────┐
192       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
193       ├─────────────────────────────┼─────────────────────────────┤
194       │Interface Stability          │Evolving                     │
195       ├─────────────────────────────┼─────────────────────────────┤
196       │MT-Level                     │Safe                         │
197       └─────────────────────────────┴─────────────────────────────┘
198

SEE ALSO

200       ct_event_free(3CONTRACT), ct_event_read(3CONTRACT), ct_event_read_crit‐
201       ical(3CONTRACT),    libcontract(3LIB),     contract(4),     process(4),
202       attributes(5), lfcompile(5)
203
204
205
206SunOS 5.11                        19 Jul 2004   ct_pr_event_get_pid(3CONTRACT)
Impressum