Contract Management Library Functions
ctpreventgetpid(3CONTRACT)
NAME
ctpreventgetpid, ctpreventgetppid,
ctpreventgetsignal, ctpreventgetsender,
ctpreventgetsenderct, ctpreventgetexitstatus,
ctpreventgetpcorefile, ctpreventgetgcorefile,
ctpreventgetzcorefile - process contract event functions
SYNOPSIS
cc [ flag... ] file... -DLARGEFILE64SOURCE -lcontract [ library... ]
#include
#include
int ctpreventgetpid(ctevthdlt evthdl, pidt *pidp);
int ctpreventgetppid(ctevthdlt evthdl, pidt *pidp);
int ctpreventgetsignal(ctevthdlt evthdl, int *signalp);
int ctpreventgetsender(ctevthdlt evthdl, pidt *pidp);
int ctpreventgetsenderct(ctevthdlt evthdl, ctidt *pidp);
int ctpreventgetexitstatus(ctevthdlt evthdl, int *statusp);
int ctpreventgetpcorefile(ctevthdlt evthdl, char **namep);
int ctpreventgetgcorefile(ctevthdlt evthdl, char **namep);
int ctpreventgetzcorefile(ctevthdlt evthdl, char **namep);
DESCRIPTION
These functions read process contract event information from
an event object returned by cteventread(3CONTRACT) or
cteventreadcritical(3CONTRACT).
The ctpreventgetpid() function reads the process ID of
the process generating the event.
The ctpreventgetppid() function reads the process ID of
the process that forked the new process causing the
SunOS 5.11 Last change: 19 Jul 2004 1
Contract Management Library Functions
ctpreventgetpid(3CONTRACT)
CTPREVFORK event.
The ctpreventgetsignal() function reads the signal
number of the signal that caused the CTPREVSIGNAL event.
The ctpreventgetsender() function reads the process ID
of the process that sent the signal that caused the
CTPREVSIGNAL 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 ctpreventgetsenderct function reads the contract ID
of the process that sent the signal that caused the
CTPREVSIGNAL event. If the signal's sender was not in the
same zone as the signal's recipient, this information is
available only
The ctpreventgetexitstatus() function reads the exit
status of the process generating a CTPREVEXIT event.
The ctpreventgetpcorefile() function reads the name of
the process core file if one was created when the
CTPREVCORE event was generated. A pointer to a character
array is stored in *namep and is freed when
cteventfree(3CONTRACT) is called on the event handle.
The ctpreventgetgcorefile() function reads the name of
the zone's global core file if one was created when the
CTPREVCORE event was generated. A pointer to a character
array is stored in *namep and is freed when cteventfree()
is called on the event handle.
The ctpreventgetzcorefile() function reads the name of
the system-wide core file in the global zone if one was
created when the CTPREVCORE 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 *namep
and is freed when cteventfree() is called on the event
handle.
RETURN VALUES
Upon successful completion, ctpreventgetpid(),
ctpreventgetppid(), ctpreventgetsignal(),
ctpreventgetsender(), ctpreventgetsenderct(),
SunOS 5.11 Last change: 19 Jul 2004 2
Contract Management Library Functions
ctpreventgetpid(3CONTRACT)
ctpreventgetexitstatus(), ctpreventgetpcorefile(),
ctpreventgetgcorefile(), and ctpreventgetzcorefile()
return 0. Otherwise, they return a non-zero error value.
ERORS
The ctpreventgetpid(), ctpreventgetppid(),
ctpreventgetsignal(), ctpreventgetsender(),
ctpreventgetsenderct(), ctpreventgetexitstatus(),
ctpreventgetpcorefile(), ctpreventgetgcorefile(),
and ctpreventgetzcorefile() functions will fail if:
EINVAL The evthdl argument is not a process contract
event object.
The ctpreventgetppid(), ctpreventgetsignal(),
ctpreventgetsender(), ctpreventgetsenderct(),
ctpreventgetexitstatus(), ctpreventgetpcorefile(),
ctpreventgetgcorefile(), and ctpreventgetzcorefile()
functions will fail if:
EINVAL The requested data do not match the event type.
The ctpreventgetsender()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 in
a non-global zone and the sender was in a dif-
ferent zone.
The ctpreventgetpcorefile(),
ctpreventgetgcorefile(), and ctpreventgetzcorefile()
functions will fail if:
ENOENT The requested core file was not created.
The ctpreventgetzcorefile() function will fail if:
ENOENT The event object was read by a process running in
a non-global zone.
EXAMPLES
SunOS 5.11 Last change: 19 Jul 2004 3
Contract Management Library Functions
ctpreventgetpid(3CONTRACT)
Example 1 Print the instigator of all CTPREVSIGNAL
events.
Open the process contract bundle. Loop reading events. Fetch
and display the signalled pid and signalling pid for each
CTPREVSIGNAL event encountered.
#include
#include
#include
#include
...
int fd;
ctevthdlt event;
pidt pid, sender;
fd = open("/system/contract/process/bundle", ORDONLY);
for (;;) {
cteventread(fd, &event);
if (cteventgettype(event) != CTPREVSIGNAL) {
cteventfree(event);
continue;
}
ctpreventgetpid(event, &pid);
if (ctpreventgetsender(event, &sender) == ENOENT)
printf("process %ld killed by unknown process\n",
(long)pid);
else
printf("process %ld killed by process %ld\n",
(long)pid, (long)sender);
cteventfree(event);
}
...
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
SunOS 5.11 Last change: 19 Jul 2004 4
Contract Management Library Functions
ctpreventgetpid(3CONTRACT)
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability Evolving
MT-Level Safe
SEE ALSO
cteventfree(3CONTRACT), cteventread(3CONTRACT),
cteventreadcritical(3CONTRACT), libcontract(3LIB), con-
tract(4), process(4), attributes(5), lfcompile(5)
SunOS 5.11 Last change: 19 Jul 2004 5
Contract Management Library Functions
ctpreventgetpid(3CONTRACT)
SunOS 5.11 Last change: 19 Jul 2004 6
|