Go to main content

man pages section 3: Extended Library Functions, Volume 3

Exit Print View

Updated: Thursday, June 13, 2019
 
 

Penv_iter (3PROC)

Name

Pgetenv, Penv_iter - search the environment list of a victim process

Synopsis

#include <libproc.h>
char *Pgetenv(ps_prochandle_t *Pr, const char *name,
         char *buf, size_t buflen);
typedef int proc_env_f(void *data, ps_prochandle_t *Pr,
         uintptr_t addr, const char *nameval);
int Penv_iter(ps_prochandle_t *Pr, proc_env_f *func, void *data);

Description

The Pr argument identifies a victim process or core file attached to the controlling process by the create and grab interfaces. For more information, see the Pcreate(3PROC) and Pgrab(3PROC) man pages.

The Pgetenv() function searches the environment list of the victim process for a string of the form name=value and, if the string is present, the function copies the value into the buffer of the caller named by the buf argument for up to buflen bytes and returns the buf pointer. The returned string is always null-terminated, even when the victim's string length exceeds the buflen argument of the caller.

The Penv_iter() function iterates over all entries in the environment list of the victim process and calls the specified function for each such entry, passing it the specified data argument, the process handle, the address in the victim process where the name-value string of the environment was found, and a pointer to the name-value string that was retrieved from the victim process which is valid only for the one call to the specified function. The iteration is terminated if the specified function returns a non-zero value. For more information, see the environ(7) man page.

Return Values

If successful, the Pgetenv() function returns a pointer to the value string in the caller's buffer. Else, it returns a NULL pointer.

The Penv_iter() function returns 0 if it iterates through the entire environment list of the victim process. Else, it returns the non-zero value returned by the call to the specified function that caused the iteration to terminate.

The errno value is not set by these functions.

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
Unsafe

See Also

libproc.h(3HEAD), libproc(3LIB), Pcreate(3PROC), Pgrab(3PROC), proc(5), environ(7)