xref: /illumos-gate/usr/src/man/man3proc/Plwp_iter.3proc (revision dcbf3bd6a1f1360fc1afcee9e22c6dcff7844bf2)
1.\"
2.\" This file and its contents are supplied under the terms of the
3.\" Common Development and Distribution License ("CDDL"), version 1.0.
4.\" You may only use this file in accordance with the terms of version
5.\" 1.0 of the CDDL.
6.\"
7.\" A full copy of the text of the CDDL should have accompanied this
8.\" source.  A copy of the CDDL is also available via the Internet at
9.\" http://www.illumos.org/license/CDDL.
10.\"
11.\"
12.\" Copyright 2015 Joyent, Inc.
13.\"
14.Dd May 11, 2016
15.Dt PLWP_ITER 3PROC
16.Os
17.Sh NAME
18.Nm Plwp_iter ,
19.Nm Plwp_iter_all
20.Nd iterate over threads
21.Sh SYNOPSIS
22.Lb libproc
23.In libproc.h
24.Ft int
25.Fo Plwp_iter
26.Fa "struct ps_prochandle *P"
27.Fa "proc_lwp_f *func",
28.Fa "void *data"
29.Fc
30.Ft int
31.Fo Plwp_iter_all
32.Fa "struct ps_prochandle *P"
33.Fa "proc_lwp_all_f *func"
34.Fa "void *data"
35.Fc
36.Sh DESCRIPTION
37The
38.Fn Plwp_iter
39and
40.Fn Plwp_iter_all
41functions iterates over threads in the given process handle
42.Fa P .
43The
44.Fn Plwp_iter
45function iterates over all active threads, where as the
46.Fn Plwp_iter_all
47function iterates over both active threads and zombie threads -- threads
48waiting to be reaped.
49.Pp
50For each thread, the callback function
51.Fa func
52is called with the pointer to the private data argument,
53.Fa data ,
54and the thread's
55.Sy lwpstatus_t
56structure. In the case of the
57.Fn Plwp_iter_all
58function, the thread's
59.Sy lwpsinfo_t
60is also included.
61.Pp
62The return value of
63.Fa func
64controls whether or not iteration continues. If
65.Fa func
66returns
67.Sy 0 ,
68then both functions will continue iteration. However, if
69.Fa func
70returns non-zero, then iteration will halt and that value will be used
71as the return value of the
72.Fn Plwp_iter
73and
74.Fn Plwp_iter_all
75functions. Because both functions return
76.Sy -1
77on internal failure, it is recommended that the callback function does
78not return
79.Sy -1
80to indicate an error so that the caller may distinguish between the
81failure of the callback function and the failure of the
82.Fn Plwp_iter
83and
84.Fn Plwp_iter_all
85functions.
86.Sh RETURN VALUES
87Upon successful completion, the
88.Fn Plwp_iter
89and
90.Fn Plwp_iter_all
91functions return
92.Sy 0 .
93Otherwise, if there was an internal error or there is no thread data, then
94.Sy -1
95is returned. Otherwise, if the callback function
96.Fa func
97returns non-zero, then its return value will be returned instead.
98.Sh INTERFACE STABILITY
99.Sy Uncommitted
100.Sh MT-LEVEL
101See
102.Sy LOCKING
103in
104.Xr libproc 3LIB .
105.Sh SEE ALSO
106.Xr libproc 3LIB
107