PREAD(3PROC) Process Control Library Functions PREAD(3PROC)
NAME
Pread,
Pread_string - read data from a process
LIBRARY
Process Control Library (libproc, -lproc)
SYNOPSIS
#include <libproc.h> ssize_t Pread(
struct ps_prochandle *P,
void *buf,
size_t nbytes,
uintptr_t address);
ssize_t Pread_string(
struct ps_prochandle *P,
char *buf,
size_t nbytes,
uintptr_t address);
DESCRIPTION
The
Pread() function reads data from the process handle
P starting at
address in the address space of the process and reads at most
nbytes of
data into
buf and is logically analogous to the
pread(2) function.
For live processes, this function is equivalent to reading from the
/proc file system
as file for the process. For core files and file
handles, it reads and writes from the logical address space and not the
corresponding offset of the file itself. For example, a core file
contains a sparse representation of the address space of a crashed
process and unmapped regions are not present in the file. However,
address still refers to the virtual addresses that were present at run-
time and not those in the core file.
The
Pread_string() function is similar to the
Pread() function, except
that it attempts to interpret
address as a null terminated character
string and will stop reading characters into
buf if either
nbytes has
been read or a null terminator is encountered. The resulting data in
buf will always be null terminated, even if no null terminator was
found in the first
nbytes of data.
RETURN VALUES
Upon successful completion, the
Pread() and
Pread_string() functions
return a non-negative integer indicating the number of bytes actually
read. Otherwise, the functions return
-1 and set
errno to indicate the
error.
ERRORS
For a full list of possible errors also see the
DIAGNOSTICS section in
proc(5) and the
ERRORS section in
pread(2).
INTERFACE STABILITY
UncommittedMT-LEVEL See
LOCKING in
libproc(3LIB).
SEE ALSO
pread(2),
libproc(3LIB),
proc(5)illumos May 11, 2016 illumos