summaryrefslogtreecommitdiff
path: root/usr/src/man/man3proc/proc_get_fdinfo.3proc
blob: 1985230f4c3c2842515dc7eaef7ef5c88dee56b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
.\"
.\" This file and its contents are supplied under the terms of the
.\" Common Development and Distribution License ("CDDL"), version 1.0.
.\" You may only use this file in accordance with the terms of version
.\" 1.0 of the CDDL.
.\"
.\" A full copy of the text of the CDDL should have accompanied this
.\" source.  A copy of the CDDL is also available via the Internet at
.\" http://www.illumos.org/license/CDDL.
.\"
.\"
.\" Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
.\"
.Dd January 29, 2020
.Dt PROC_GET_FDINFO 3PROC
.Os
.Sh NAME
.Nm proc_get_fdinfo ,
.Nm proc_fdinfo_free
.Nd get process file descriptor information
.Sh LIBRARY
.Lb libproc
.Sh SYNOPSIS
.In libproc.h
.Ft prfdinfo_t *
.Fo proc_get_fdinfo
.Fa "pid_t pid"
.Fa "int fd"
.Fc
.Ft "void"
.Fo proc_fdinfo_free
.Fa "prfdinfo_t *info"
.Fc
.Sh DESCRIPTION
The
.Fn proc_get_fdinfo
function is a convenient way to read the
.Pa /proc/pid/fdinfo/fd
file for the process
.Fa pid
and file descriptor
.Fa fd .
On success, the return value of the function is a pointer to a properly
terminated
.Sy prfdinfo_t
structure.
.Pp
The definition of the
.Vt prfdinfo_t
structure may be found in
.Xr proc 4 .
.Pp
The caller must free the returned memory by calling the
.Fn proc_fdinfo_free
function.
.Pp
The
.Fn proc_fdinfo_free
frees all memory associated with the
.Vt prfdinfo_t
structure passed as
.Fa info .
.Sh RETURN VALUES
Upon successful completion, the
.Fn proc_get_fdinfo
function returns a pointer to an allocated
.Vt prfdinfo_t
structure.
Otherwise,
.Dv NULL
is returned to indicate an error occurred and
.Vt errno
is set to indicate the error.
.Sh ERRORS
In addition to the errors listed below, the
.Fn proc_get_fdinfo
function may fail for the same reasons as the
.Xr fstat 2 ,
.Xr lseek 2 ,
.Xr malloc 3C ,
.Xr open 2 ,
and
.Xr read 2
functions.
The
.Fn proc_get_fdinfo
function will fail if:
.Bl -tag -width Er
.It Er EIO
The data read from the file under
.Pa /proc
is not properly terminated.
.El
.Sh INTERFACE STABILITY
.Sy Uncommitted
.Sh MT-LEVEL
.Sy MT-Safe
.Sh SEE ALSO
.Xr libproc 3LIB ,
.Xr proc 4