READPROC(3)

πŸ“¦ version 3.3.17, in centos-stream 9, ubuntu jammy

READPROC(3) πŸ’–

okay bestie, welcome to the Linux Programmer's Manual β€” this one's a classic, it's giving very much "reading straight out of /proc" energy. no cap.


✨ NAME ✨

readproc, freeproc β€” read information from next /proc/## entry πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <proc/readproc.h>

proc_t* readproc(PROCTAB *PT, proc_t *return_buf);
void freeproc(proc_t *p);

πŸ’… DESCRIPTION πŸ’…

so readproc literally reads the info for the next process that matches the criteria you specified over in PT, and fills it all into a proc_t structure. main character behavior fr fr.

now here's the tea on return_buf β˜• β€” if it's not NULL, it's gonna use the struct that return_buf is pointing at. but if it is NULL? it allocates a brand-new proc_t structure and hands you back a pointer to it. slay.

⚠️ heads up bestie: note that (if so specified in PT) readproc always allocates memory if it fills in the environ or cmdline parts of proc_t. that memory is yours to deal with, so don't forget it exists 😭

freeproc frees all the memory allocated for the proc_t struct *p. she's the cleanup crew, the girl who brings the trash bag to the function, we love her 🫢

the proc_t structure is defined in <proc/readproc.h> β€” please go look there for a definition of all the fields, i'm not retyping that whole thing, it's giving novella πŸ“–


⭐ RETURN VALUE ⭐

readproc returns a pointer to the next proc_t, or NULL if there are no more processes left. that's it, that's the ending. no more girlies in the queue πŸ’€


🌸 SEE ALSO 🌸


πŸŽ€ REPORTING BUGS πŸŽ€

found a bug? spill the tea, bestie β€” please send bug reports to procps@freelists.org πŸ’Œ


and that's the whole page, periodt. this little icon was brought to you by the Linux Manpage, dated 14 July 2014 β€” okurrr, mwah, bye bestie πŸ’‹πŸ‘‘

πŸ“¦ where this page comes from