getrpcent_r(3)
π getrpcent_r(3) β bestie edition π
okay so this is the getrpcent_r(3) page, straight out of the Library Functions Manual, and we're gonna make RPC lookups (but reentrant, aka thread-safe-ish, aka the β¨responsibleβ¨ version) make sense. grab a strawberry π and let's go.
β¨ NAME β¨
getrpcent_r, getrpcbyname_r, getrpcbynumber_r β get RPC entry (reentrant)
like, it's the same energy as the regular ones but reentrant, which is the whole point, iykyk π
π LIBRARY π
Standard C library (libc, -lc)
π SYNOPSIS π
#include <netdb.h>
int getrpcent_r(size_t size;
struct rpcent *result_buf, char buf[size],
size_t size, struct rpcent **result);
int getrpcbyname_r(size_t size;
const char *name,
struct rpcent *result_buf, char buf[size],
size_t size, struct rpcent **result);
int getrpcbynumber_r(size_t size;
int number,
struct rpcent *result_buf, char buf[size],
size_t size, struct rpcent **result);
πΈ Feature Test Macro Requirements for glibc πΈ
(peep feature_test_macros(7) if you're like "what is a feature test macro bestie")
getrpcent_r(), getrpcbyname_r(), getrpcbynumber_r():
- Since glibc 2.19:
_DEFAULT_SOURCE - glibc 2.19 and earlier:
_BSD_SOURCE||_SVID_SOURCE
π DESCRIPTION π
So. getrpcent_r(), getrpcbyname_r(), and getrpcbynumber_r() are the reentrant equivalents of, respectively, getrpcent(3), getrpcbyname(3), and getrpcbynumber(3). iconic family reunion π«Ά They're different in how the rpcent structure comes back to you, and in the function calling signature and return value. This page is literally just the differences from the nonreentrant girlies β that's it, that's the assignment.
Instead of handing you back a pointer to a statically allocated rpcent structure as the function result, these functions copy the structure into the spot pointed to by result_buf. no shared static state, no drama, periodt β¨
The buf array is where the string fields live that the returned rpcent structure points to. (The nonreentrant versions allocate those strings in static storage, which is the messy part.) You tell it how big that array is in size. If buf is too small the call just fails with the error ERANGE and you gotta try again with a bigger buffer, bestie. π (a buffer of size 1024 bytes should be sufficient for most applications β lowkey the magic number)
If the function call successfully obtains an RPC record, then *result gets set pointing to result_buf; otherwise, *result is set to NULL. simple as that π«
π₯ RETURN VALUE π₯
On success, these functions return 0. On error, they return one of the positive error numbers listed in ERRORS.
On error, record not found (getrpcbyname_r(), getrpcbynumber_r()), or end of input (getrpcent_r()) β *result is set to NULL. π«
π ERRORS π
ENOENT(getrpcent_r()) β No more records in database. that's it, that's the end of the feed, no more scrolling πERANGEβbufis too small. Try again with a larger buffer (and increasedsize). not me underestimating the buffer again π
π ATTRIBUTES π
For an explanation of the terms used in this section, see attributes(7).
- Interface:
getrpcent_r(),getrpcbyname_r(),getrpcbynumber_r() - Attribute: Thread safety
- Value: MT-Safe locale
π VERSIONS π
Functions with similar names exist on some other systems, though typically with different calling signatures. so likeβ¦ don't assume the vibes transfer, okay? π check the signature before you copy-paste, fr fr.
β STANDARDS β
GNU.
π¦ SEE ALSO π¦
okay that's the whole page, you ate that π
π and for the cute sign-off: this was Linux man-pages 6.20, dated 2025-06-28, and yes we're still on the getrpcent_r(3) page. main character energy only. bye bestie πβ¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms