LGRAB(3PROC) | Process Control Library Functions | LGRAB(3PROC) |
Lgrab
— obtain a
handle to control a thread
Process Control Library (libproc, -lproc)
#include
<libproc.h>
struct ps_lwphandle *
Lgrab
(struct ps_prochandle *P,
lwpid_t lwpid, int *perr);
The
Lgrab
()
function obtains a control handle to the thread identified by
lwpid residing under the process
P. This handle is then passed as argument to other
libproc
routines. The lwpid can be obtained from the
pr_lwpid
member of the
lwpstatus_t
structure.
The perr argument must point to
a valid pointer that will be used to store an error code in the event that
Lgrab
() is
unable to successfully obtain a handle to the process. The possible errors
are defined below in the ERRORS section.
The code may be transformed into a human readable string through the use of
Lgrab_error(3PROC).
The handle to the thread is valid until the
Lfree(3PROC) function is called,
which also releases associated resources from the handle. Only a single
handle to a specific thread may exist at any time. If the handle already
exists and another caller attempts to grab that thread, it will result in an
error. The caller must call
Lfree
()
before releasing the handle associated with P.
Unlike grabbing a process, grabbing a thread does not change the current state of the thread. If it is running, it will remain running. If it is stopped, it will remain stopped.
Upon successful completion, the Lgrab
()
function returns a pointer to the control handle for the specified thread.
Otherwise, the NULL
pointer is returned and
perr is set to indicate the error.
The Lgrab
() function will fail if:
G_BUSY
G_NOPROC
G_STRANGE
errno(3C), libproc(3LIB), Lfree(3PROC), Lgrab_error(3PROC), proc(5)
November 27, 2023 | OmniOS |