Pcwd(3PROC) | Process Control Library Functions | Pcwd(3PROC) |
Pcwd
, Pcwd_free
— get process current working directory
information
Process Control Library (libproc, -lproc)
#include
<libproc.h>
int
Pcwd
(struct ps_prochandle *P,
prcwd_t **cwdp);
void
Pcwd_free
(prcwd_t *cwd);
The
Pcwd
()
function obtains the current working directory and related information about
the file system it is contained upon of the process handle
P. This information is synthesized for live processes
and is obtained from the NT_CWD
elf note for core
files. It is not supported on handles that refer to idle
(PS_IDLE
) processes.
The library will allocate the memory needed for a
prcwd_t structure. A pointer to this data will be
stored in cwdp. It is the callers responsibility to
release it by calling the
Pcwd_free
()
function and passing it back in the cwd argument. The
allocated data stored in cwdp has a lifetime
independent of the process handle, P. In other words,
the data in cwdp may be used after someone has called
Prelease(3PROC) or
Pfree(3PROC) on
P.
The prcwd_t structure is defined in
<sys/procfs.h>
and discussed
in more detail in core(5). The various
path related strings are NUL-terminated character strings that may not be
valid in the calling process's locale.
Upon successful completion, the Pwcd
()
function returns
0 and stores the
allocated prcwd_t structure in
cwdp. Otherwise
-1 is returned
and errno is set to indicate the error.
The Pcwd
() functions will fail if:
EAGAIN,
ENOMEM
ENODATA
NT_CWD
ELF note.ENOTSUP
Additional errors may be generated based on the type of process handle that is present.
See LOCKING in libproc(3LIB).
May 10, 2024 | OmniOS |