KINFO_GETFILE(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’– NAME πŸ’– β€” KINFO_GETFILE(3) from the Library Functions Manual πŸ’–

okay so bestie, this is the page for kinfo_getfile β€” literally the function for getting per-process file descriptor information ✨


🧚 LIBRARY 🧚

System Utilities Library (libutil, -lutil) β€” yes, link it with -lutil πŸ’…


✨ SYNOPSIS ✨

#include <sys/types.h>
#include <sys/user.h>
#include <libutil.h>

struct kinfo_file *
kinfo_getfile(pid_t pid, int *cntp);

🌸 DESCRIPTION 🌸

This function is used for obtaining the file descriptor information of a particular process. Obsessed with the specificity πŸ’–

The pid field contains the process identifier. This should be a process that you have privilege to access. The cntp field lets the caller know how many records are returned β€” cute little out-param moment πŸŽ€

This function is a wrapper around sysctl(3) with the KERN_PROC_FILEDESC mib. While the kernel returns a packed structure, this function expands the data into a fixed record format. The way it unpacks for you? Iconic πŸ¦‹


πŸ’€ RETURN VALUES πŸ’€

On success the kinfo_getfile() function returns a pointer to an array of struct kinfo_file structures as defined by <sys/user.h>. The array was obtained by an internal call to malloc(3) and must be freed by the caller with a call to free(3). On failure the kinfo_getfile() function returns NULL.

bestie, do not forget: the array must be freed by the caller with free(3) 🫢

πŸ‘‘ SEE ALSO πŸ‘‘


πŸ¦‹ HISTORY πŸ¦‹

The kinfo_getfile() function first appeared in FreeBSD 7.0. periodt ✨


xoxo, your Debian bestie πŸ’– β€” this page is dated May 27, 2015, and the footer is literally KINFO_GETFILE(3) 🌈

πŸ“¦ where this page comes from