PMAPPING_ITER(3PROC) Process Control Library Functions PMAPPING_ITER(3PROC)

Pmapping_iter, Pmapping_iter_resolved, Pobject_iter, Pobject_iter_resolvediterate over process mappings and objects

Process Control Library (libproc, -lproc)

#include <libproc.h>

int
Pmapping_iter(struct ps_prochandle *P, proc_map_f *func, void *data);

int
Pmapping_iter_resolved(struct ps_prochandle *P, proc_map_f *func, void *data);

int
Pobject_iter(struct ps_prochandle *P, proc_map_f *func, void *data);

int
Pobject_iter_resolved(struct ps_prochandle *P, proc_map_f *func, void *data);

The () and () functions iterate over the memory mappings in the process represented by P.

For each memory mapping, the callback function func will be invoked and it will be passed the data argument, the structure defined from proc(5), and a name of the mapping. The way that the name is obtained varies based on whether one calls () or (). In both cases, the dynamic linker is consulted to determine the file name for the mapping, if it's known. If the name is unknown, for example an anonymous mapping, then the NULL pointer is passed in for the name. In the case of the Pmapping_iter_resolved() function the system tries to resolve it to a complete file system path. If that fails, it falls back to the information from the dynamic linker, before returning NULL in the case of not being able to find any name. For more information on the signature of the proc_map_f, see libproc(3LIB).

The return value of func controls whether or not iteration continues. If func returns then iteration continues. If func returns non-zero then iteration will halt and the value will be returned to the caller. Because -1 indicates internal failure, it is recommended that the callback function not return -1 to indicate an error itself. This allows the caller to distinguish between failure of the callback function versus failure of the () and () functions.

The () and () functions are similar to the Pmapping_iter() and Pmapping_iter_resolved() functions. Except, rather than iterating over every mapping, they iterate over the objects that the process has loaded by the dynamic linker. For example, an anonymous mapping will show up when iterating mappings, but will not show up when iterating objects. Further, while most dynamic shared objects have multiple mappings for the text and data sections, there will only be a single object that is iterated over.

The distinction between the () and () functions is identical to the difference in name resolution between the Pmapping_iter() and Pmapping_iter_resolved() functions.

Upon successful completion, the Pmapping_iter(), Pmapping_iter_resolved() Pobject_iter(), and Pobject_iter_resolved() functions return Otherwise, if there was an internal error then -1 is returned. Otherwise, if the callback function func returns non-zero, then its return value will be returned instead.

See in libproc(3LIB).

libproc(3LIB), proc(5)

May 11, 2016 OmniOS