getcontext(2)
NAME
getcontext − return process context for context-dependent file search
SYNOPSIS
#include <unistd.h>
int getcontext(char *contextbuf, size_t length);
DESCRIPTION
getcontext() reads the per-process context (see context(5)) into the buffer pointed to by contextbuf. The context is returned as a null-terminated string containing a blank-separated list of names. The function value returned by getcontext() is the length of this string, including the null terminator. If this string, including the null terminator, is less than length bytes, a truncated, null-terminated string of length bytes is returned. In particular, if length is zero, only the function value is returned.
RETURN VALUE
Upon successful completion, the length of the context string, including the null terminator, is returned. Otherwise, a value of −1 is returned and errno is set to indicate the error.
ERRORS
getcontext() may fail if the following is true:
[EFAULT] contextbuf points to an illegal address. Reliable detection of this error is not guaranteed.
EXAMPLES
In the following example getcontext() is called once with a length parameter of zero to determine the size of a buffer to allocate for the context.
int length;
char *contextbuf;
length = getcontext ((char *)0, 0);
contextbuf = malloc (length);
(void) getcontext (contextbuf, length);
AUTHOR
getcontext() was developed by HP.
SEE ALSO
getcontext(1), cnodeid(2), cnodes(2), cdf(4), context(5).
Hewlett-Packard Company — HP-UX Release 9.0: August 1992