explain_getrusage(3)
π explain_getrusage β the libexplain page, bestie edition π
okay so this is explain_getrusage(3), a manual page from the Library Functions Manual (yes the libexplain girlies know). it's literally the page that explains getrusage(2) errors to you in human words instead of just yelling a number at your face. no cap. π¦
β¨ NAME β¨
explain_getrusage β explain getrusage(2) errors π
πΈ SYNOPSIS πΈ
#include <libexplain/getrusage.h>
const char *explain_getrusage(int who, struct rusage *usage);
const char *explain_errno_getrusage(int errnum, int who, struct rusage *usage);
void explain_message_getrusage(char *message, int message_size, int who, struct rusage *usage);
void explain_message_errno_getrusage(char *message, int message_size, int errnum, int who, struct rusage *usage);
π DESCRIPTION π
These functions may be used to obtain explanations for errors returned by the getrusage(2) system call. like, that's the whole gig. the vibe is: system call goes wrong β these girls tell you why. π
π explain_getrusage
const char *explain_getrusage(int who, struct rusage *usage);
The explain_getrusage function is used to obtain an explanation of an error returned by the getrusage(2) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. it's giving overachiever and we love that for it. β¨
The errno global variable will be used to obtain the error value to be decoded.
whoβ The original who, exactly as passed to thegetrusage(2)system call. no touchy, no renaming, just the same value you handed over. πusageβ The original usage, exactly as passed to thegetrusage(2)system call.
Returns: The message explaining the error. This message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. This will be overwritten by the next call to any libexplain function which shares this buffer, including other threads. π shared buffer, shared struggles.
Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. fr fr, do not come for me if your threads start fighting over it. π
Example: This function is intended to be used in a fashion similar to the following example:
if (getrusage(who, usage) < 0)
{
fprintf(stderr, "%s\n", explain_getrusage(who, usage));
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_getrusage_or_die(3) function. bestie behaviour honestly, it already did the work for you. π«Ά
π explain_errno_getrusage
const char *explain_errno_getrusage(int errnum, int who, struct rusage *usage);
The explain_errno_getrusage function is used to obtain an explanation of an error returned by the getrusage(2) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. iconic, honestly. π
errnumβ The error value to be decoded, usually obtained from theerrnoglobal variable just before this function is called. This is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value oferrno. so like, graberrnoearly, it does NOT stay put. β οΈwhoβ The original who, exactly as passed to thegetrusage(2)system call.usageβ The original usage, exactly as passed to thegetrusage(2)system call.
Returns: The message explaining the error. This message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. This will be overwritten by the next call to any libexplain function which shares this buffer, including other threads. same shared-buffer drama, different function. π
Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. periodt. π
Example: This function is intended to be used in a fashion similar to the following example:
if (getrusage(who, usage) < 0)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_getrusage(err, who, usage));
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_getrusage_or_die(3) function.
π explain_message_getrusage
void explain_message_getrusage(char *message, int message_size, int who, struct rusage *usage);
The explain_message_getrusage function is used to obtain an explanation of an error returned by the getrusage(2) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. it's the you supply the buffer edition, main character energy. π
The errno global variable will be used to obtain the error value to be decoded.
messageβ The location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe. β¨ you bring the buffer, you get the thread safety. that's the deal.message_sizeβ The size in bytes of the location in which to store the returned message.whoβ The original who, exactly as passed to thegetrusage(2)system call.usageβ The original usage, exactly as passed to thegetrusage(2)system call.
Example: This function is intended to be used in a fashion similar to the following example:
if (getrusage(who, usage) < 0)
{
char message[3000];
explain_message_getrusage(message, sizeof(message), who, usage);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_getrusage_or_die(3) function.
π explain_message_errno_getrusage
void explain_message_errno_getrusage(char *message, int message_size, int errnum, int who, struct rusage *usage);
The explain_message_errno_getrusage function is used to obtain an explanation of an error returned by the getrusage(2) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. the final boss of this page, and yes she ate. π₯
messageβ The location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe. π§message_sizeβ The size in bytes of the location in which to store the returned message.errnumβ The error value to be decoded, usually obtained from theerrnoglobal variable just before this function is called. This is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value oferrno. again: save thaterrnofirst, it is not loyal. πwhoβ The original who, exactly as passed to thegetrusage(2)system call.usageβ The original usage, exactly as passed to thegetrusage(2)system call.
Example: This function is intended to be used in a fashion similar to the following example:
if (getrusage(who, usage) < 0)
{
int err = errno;
char message[3000];
explain_message_errno_getrusage(message, sizeof(message), err, who, usage);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_getrusage_or_die(3) function.
π¦ SEE ALSO π¦
getrusage(2)β get resource usageexplain_getrusage_or_die(3)β get resource usage and report errors
π COPYRIGHT π
libexplain version 1.4 Copyright (C) 2013 Peter Miller
and that's the whole page bestie, tysm for reading π this was explain_getrusage(3) from libexplain version 1.4, copyright (C) 2013 Peter Miller β go forth, decode your errors, and remember: the buffer is shared, the errno is fleeting, but you? you're slaying. π
β¨πΈπ¦π
π¦ where this page comes from
- debian bookworm: libexplain-dev 1.4.D001-12+b1 Β· LGPL-3.0-or-later
- debian trixie: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- ubuntu jammy: libexplain-dev 1.4.D001-12 Β· LGPL-3.0-or-later
- ubuntu noble: libexplain-dev 1.4.D001-13 Β· LGPL-3.0-or-later
- ubuntu resolute: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- Copyright (C) 2013 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms