PROC_LWP_IN_SET(3PROC) | Process Control Library Functions | PROC_LWP_IN_SET(3PROC) |

`proc_lwp_in_set`

,
`proc_lwp_range_valid`

— test
and validate thread ranges

Process Control Library (libproc, -lproc)

```
#include
<libproc.h>
```

`int`

`proc_lwp_in_set`

(`const char *set`,
`lwpid_t lwpid`);

`int`

`proc_lwp_range_valid`

(`const char
*set`);

The
`proc_lwp_in_set`

()
and `proc_lwp_range_valid`

() functions provide means
for testing the validity of thread ranges and whether a thread is in a
range.

A thread range is a series of one or more series of range identifiers which describe a collection of threads. These are often used by programs such as pbind(8), pstack(1), prun(1), pstop(1), and others as a means for a user to specify a selection of threads from inside of a process.

More formally, the thread range may be described as:

lwp_range[,lwp_range]*

An LWP range may be specified as one of the following four strings. The following table shows the string formats and the corresponding set of valid threads that match it:

-n |
lwpid <= n |

n-m |
n <= lwpid <= m |

n- |
lwpid >= n |

n |
lwpid == n |

For example, the thread range
**-2,4-5,7,8-**
matches thread with IDs 0-2, 4-5, 7, and any thread id 8 or greater.

The
`proc_lwp_range_valid`

()
function determines whether or not the character string
`set` is a valid thread range based on the rules above.
Note, the empty string, the `NULL`

pointer, or
otherwise are not valid.

The
`proc_lwp_in_set`

()
function determines whether the thread identifier
`lwpid` is contained in the set described by
`set`. If `set` is the
`NULL`

pointer, then every thread matches the set.

Upon successful completion, the
`proc_lwp_in_set` function returns **1**
to indicate `lwpid` is in `set`.
Otherwise, **0** is returned to indicate that
`lwpid` is not in `set`.

Upon successful completion, the
`proc_lwp_range_valid` function returns
**0** to indicate `set` is valid.
Otherwise, **-1** is returned to indicate that the set is
invalid.

November 27, 2023 | OmniOS |