xref: /netbsd-src/lib/libkvm/kvm_getlwps.3 (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1.\"	$NetBSD: kvm_getlwps.3,v 1.4 2004/02/10 12:48:48 jmmv Exp $
2.\"
3.\"Copyright (c) 2002 The NetBSD Foundation, Inc.
4.\"All rights reserved.
5.\"
6.\"This code is derived from software contributed to The NetBSD Foundation
7.\"by Nathan J. Williams.
8.\"
9.\"Redistribution and use in source and binary forms, with or without
10.\"modification, are permitted provided that the following conditions
11.\"are met:
12.\"1. Redistributions of source code must retain the above copyright
13.\"   notice, this list of conditions and the following disclaimer.
14.\"2. Redistributions in binary form must reproduce the above copyright
15.\"   notice, this list of conditions and the following disclaimer in the
16.\"   documentation and/or other materials provided with the distribution.
17.\"3. All advertising materials mentioning features or use of this software
18.\"   must display the following acknowledgement:
19.\"       This product includes software developed by the NetBSD
20.\"       Foundation, Inc. and its contributors.
21.\"4. Neither the name of The NetBSD Foundation nor the names of its
22.\"   contributors may be used to endorse or promote products derived
23.\"   from this software without specific prior written permission.
24.\"
25.\"THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\"``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\"TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\"PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\"BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\"CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\"SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\"INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\"CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\"ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\"POSSIBILITY OF SUCH DAMAGE.
36.\"
37.Dd February 10, 2004
38.Dt KVM_GETLWPS 3
39.Os
40.Sh NAME
41.Nm kvm_getlwps
42.Nd access state of LWPs belonging to a user process
43.Sh LIBRARY
44.Lb libkvm
45.Sh SYNOPSIS
46.In kvm.h
47.In sys/param.h
48.In sys/sysctl.h
49.\" .Fa kvm_t *kd
50.br
51.Ft struct kinfo_lwp *
52.Fn kvm_getlwps "kvm_t *kd" "int pid" "u_long procaddr" "int *elemsize" "int *cnt"
53.Sh DESCRIPTION
54.Fn kvm_getlwps
55returns the set of LWPs belonging to the process specified by
56.Fa pid
57or
58.Fa procaddr
59in the kernel indicated by
60.Fa kd .
61The number of LWPs found is returned in the reference parameter
62.Fa cnt .
63The LWPs are returned as a contiguous array of
64.Sy kinfo_lwp
65structures.
66This memory is locally allocated, and subsequent calls to
67.Fn kvm_getlwps
68and
69.Fn kvm_close
70will overwrite this storage.
71.Pp
72Only the first
73.Fa elemsize
74bytes of each array entry are returned.
75If the size of the
76.Sy kinfo_lwp
77structure increases in size in a future release of
78.Nx
79the kernel will only return the requested amount of data for
80each array entry and programs that use
81.Fn kvm_getlwps
82will continue to function without the need for recompilation.
83.Pp
84If called against an active kernel, the
85.Fn kvm_getlwps
86function will use the
87.Xr sysctl 3
88interface and return information about the process identified by
89.Fa pid ;
90otherwise the kernel memory device file or swap device will be
91accessed and the process is identified by the location passed in
92.Fa paddr .
93.Sh RETURN VALUES
94.Fn kvm_getlwps
95returns
96.Dv NULL
97on failure.
98.Sh SEE ALSO
99.Xr kvm 3 ,
100.Xr kvm_close 3 ,
101.Xr kvm_geterr 3 ,
102.Xr kvm_getproc2 3 ,
103.Xr kvm_getprocs 3 ,
104.Xr kvm_nlist 3 ,
105.Xr kvm_open 3 ,
106.Xr kvm_openfiles 3 ,
107.Xr kvm_read 3 ,
108.Xr kvm_write 3
109.Sh BUGS
110These routines do not belong in the kvm interface.
111