xref: /freebsd/lib/libutil/kinfo_getproc.3 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
10daf62d9SStanislav Sedov.\"
20daf62d9SStanislav Sedov.\" Copyright (c) 2009 Ulf Lilleengen
30daf62d9SStanislav Sedov.\" All rights reserved.
40daf62d9SStanislav Sedov.\"
50daf62d9SStanislav Sedov.\" Redistribution and use in source and binary forms, with or without
60daf62d9SStanislav Sedov.\" modification, are permitted provided that the following conditions
70daf62d9SStanislav Sedov.\" are met:
80daf62d9SStanislav Sedov.\" 1. Redistributions of source code must retain the above copyright
90daf62d9SStanislav Sedov.\"    notice, this list of conditions and the following disclaimer.
100daf62d9SStanislav Sedov.\" 2. Redistributions in binary form must reproduce the above copyright
110daf62d9SStanislav Sedov.\"    notice, this list of conditions and the following disclaimer in the
120daf62d9SStanislav Sedov.\"    documentation and/or other materials provided with the distribution.
130daf62d9SStanislav Sedov.\"
140daf62d9SStanislav Sedov.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
150daf62d9SStanislav Sedov.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
160daf62d9SStanislav Sedov.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
170daf62d9SStanislav Sedov.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
180daf62d9SStanislav Sedov.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
190daf62d9SStanislav Sedov.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
200daf62d9SStanislav Sedov.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
210daf62d9SStanislav Sedov.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
220daf62d9SStanislav Sedov.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
230daf62d9SStanislav Sedov.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
240daf62d9SStanislav Sedov.\" SUCH DAMAGE.
250daf62d9SStanislav Sedov.\"
26*bc89b58dSGordon Bergling.Dd May 10, 2020
270daf62d9SStanislav Sedov.Dt KINFO_GETPROC 3
28bea977e7SJoel Dahl.Os
290daf62d9SStanislav Sedov.Sh NAME
300daf62d9SStanislav Sedov.Nm kinfo_getproc
310daf62d9SStanislav Sedov.Nd function for getting process information from kernel
320daf62d9SStanislav Sedov.Sh LIBRARY
330daf62d9SStanislav Sedov.Lb libutil
340daf62d9SStanislav Sedov.Sh SYNOPSIS
350daf62d9SStanislav Sedov.In sys/types.h
36965cd3b0SJohn Baldwin.In sys/user.h
370daf62d9SStanislav Sedov.In libutil.h
380daf62d9SStanislav Sedov.Ft struct kinfo_proc *
39d1a0cea4SRuslan Ermilov.Fn kinfo_getproc "pid_t pid"
400daf62d9SStanislav Sedov.Sh DESCRIPTION
410daf62d9SStanislav SedovThis function is used for obtaining process information from the kernel.
420daf62d9SStanislav Sedov.Pp
430daf62d9SStanislav SedovThe
440daf62d9SStanislav Sedov.Ar pid
450daf62d9SStanislav Sedovfield contains the process identifier.
463102cfe2SGlen BarberThis should be a process that you have privilege to access.
470daf62d9SStanislav SedovThis function is a wrapper around
480daf62d9SStanislav Sedov.Xr sysctl 3
490daf62d9SStanislav Sedovwith the
500daf62d9SStanislav Sedov.Dv KERN_PROC_PID
510daf62d9SStanislav Sedovmib.
520daf62d9SStanislav SedovWhile the kernel returns a packed structure, this function expands the
530daf62d9SStanislav Sedovdata into a fixed record format.
540daf62d9SStanislav Sedov.Sh RETURN VALUES
550daf62d9SStanislav SedovOn success the
560daf62d9SStanislav Sedov.Fn kinfo_getproc
570daf62d9SStanislav Sedovfunction returns a pointer to a
580daf62d9SStanislav Sedov.Vt struct kinfo_proc
590daf62d9SStanislav Sedovstructure as defined by
600daf62d9SStanislav Sedov.In sys/user.h .
610daf62d9SStanislav SedovThe pointer was obtained by an internal call to
620daf62d9SStanislav Sedov.Xr malloc 3
630daf62d9SStanislav Sedovand must be freed by the caller with a call to
640daf62d9SStanislav Sedov.Xr free 3 .
650daf62d9SStanislav SedovOn failure the
660daf62d9SStanislav Sedov.Fn kinfo_getproc
670daf62d9SStanislav Sedovfunction returns
680daf62d9SStanislav Sedov.Dv NULL .
690daf62d9SStanislav Sedov.Sh SEE ALSO
700daf62d9SStanislav Sedov.Xr free 3 ,
710daf62d9SStanislav Sedov.Xr malloc 3 ,
720daf62d9SStanislav Sedov.Xr sysctl 3
73*bc89b58dSGordon Bergling.Sh HISTORY
74*bc89b58dSGordon BerglingThe
75*bc89b58dSGordon Bergling.Fn kinfo_getproc
76*bc89b58dSGordon Berglingfunction first appeared in
77*bc89b58dSGordon Bergling.Fx 7.0 .
78