xref: /freebsd/lib/libutil/kinfo_getproc.3 (revision 965cd3b0c509ff0405f056bddc65d6c041483178)
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.\"
260daf62d9SStanislav Sedov.\" $FreeBSD$
270daf62d9SStanislav Sedov.\"
28*965cd3b0SJohn Baldwin.Dd May 27, 2015
290daf62d9SStanislav Sedov.Dt KINFO_GETPROC 3
30bea977e7SJoel Dahl.Os
310daf62d9SStanislav Sedov.Sh NAME
320daf62d9SStanislav Sedov.Nm kinfo_getproc
330daf62d9SStanislav Sedov.Nd function for getting process information from kernel
340daf62d9SStanislav Sedov.Sh LIBRARY
350daf62d9SStanislav Sedov.Lb libutil
360daf62d9SStanislav Sedov.Sh SYNOPSIS
370daf62d9SStanislav Sedov.In sys/types.h
38*965cd3b0SJohn Baldwin.In sys/user.h
390daf62d9SStanislav Sedov.In libutil.h
400daf62d9SStanislav Sedov.Ft struct kinfo_proc *
41d1a0cea4SRuslan Ermilov.Fn kinfo_getproc "pid_t pid"
420daf62d9SStanislav Sedov.Sh DESCRIPTION
430daf62d9SStanislav SedovThis function is used for obtaining process information from the kernel.
440daf62d9SStanislav Sedov.Pp
450daf62d9SStanislav SedovThe
460daf62d9SStanislav Sedov.Ar pid
470daf62d9SStanislav Sedovfield contains the process identifier.
483102cfe2SGlen BarberThis should be a process that you have privilege to access.
490daf62d9SStanislav SedovThis function is a wrapper around
500daf62d9SStanislav Sedov.Xr sysctl 3
510daf62d9SStanislav Sedovwith the
520daf62d9SStanislav Sedov.Dv KERN_PROC_PID
530daf62d9SStanislav Sedovmib.
540daf62d9SStanislav SedovWhile the kernel returns a packed structure, this function expands the
550daf62d9SStanislav Sedovdata into a fixed record format.
560daf62d9SStanislav Sedov.Sh RETURN VALUES
570daf62d9SStanislav SedovOn success the
580daf62d9SStanislav Sedov.Fn kinfo_getproc
590daf62d9SStanislav Sedovfunction returns a pointer to a
600daf62d9SStanislav Sedov.Vt struct kinfo_proc
610daf62d9SStanislav Sedovstructure as defined by
620daf62d9SStanislav Sedov.In sys/user.h .
630daf62d9SStanislav SedovThe pointer was obtained by an internal call to
640daf62d9SStanislav Sedov.Xr malloc 3
650daf62d9SStanislav Sedovand must be freed by the caller with a call to
660daf62d9SStanislav Sedov.Xr free 3 .
670daf62d9SStanislav SedovOn failure the
680daf62d9SStanislav Sedov.Fn kinfo_getproc
690daf62d9SStanislav Sedovfunction returns
700daf62d9SStanislav Sedov.Dv NULL .
710daf62d9SStanislav Sedov.Sh SEE ALSO
720daf62d9SStanislav Sedov.Xr free 3 ,
730daf62d9SStanislav Sedov.Xr malloc 3 ,
740daf62d9SStanislav Sedov.Xr sysctl 3
75