EXPLAIN_GETRUSAGE_OR_DIE(3)
β¨ explain_getrusage_or_die(3) β¨
okay so bestie, this one lives in the Library Functions Manual, and it's literally called explain_getrusage_or_die β yes the name is dramatic, no we are not sorry π
π NAME π
explain_getrusage_or_die β get resource usage and report errors
like. it gets your resource usage. and if it can't? it reports the errors. main character behaviour fr fr.
πΈ SYNOPSIS πΈ
#include <libexplain/getrusage.h>
void explain_getrusage_or_die(int who, struct rusage *usage);
int explain_getrusage_on_error(int who, struct rusage *usage);
two functions, one header, zero vibes wasted β¨
π DESCRIPTION π
so. the explain_getrusage_or_die function is used to call the getrusage(2) system call. and if that call fails? an explanation gets printed to stderr β grabbed from the explain_getrusage(3) function β and then the process terminates by calling exit(EXIT_FAILURE). like it's done. it's over. no coming back from that one π
meanwhile the explain_getrusage_on_error function also calls the getrusage(2) system call, and on failure it also prints an explanation to stderr from explain_getrusage(3) β but this one is chill, it still returns to the caller. it does not exit. it stays. π«Ά
whoβ thewho, exactly as to be passed to thegetrusage(2)system call. like, don't get creative with it, pass it through as-is π«usageβ theusage, exactly as to be passed to thegetrusage(2)system call. same energy. verbatim. no edits, no remixes π
β RETURN VALUE β
explain_getrusage_or_die only returns on success β peep getrusage(2) for more info on that. on failure? it prints an explanation and exits. it does not return. it is gone. not me waiting for a return value that is never coming π
explain_getrusage_on_error always returns the value returned by the wrapped getrusage(2) system call. every single time. consistent queen π
π¦ EXAMPLE π¦
the explain_getrusage_or_die function is intended to be used in a fashion similar to the following example:
explain_getrusage_or_die(who, usage);
that's it. that's the whole example. short, sweet, iconic π
π SEE ALSO π
getrusage(2)β get resource usageexplain_getrusage(3)β explaingetrusage(2)errorsexit(2)β terminate the calling process
iykyk, the whole little family π
π COPYRIGHT π
libexplain version 1.4 Copyright (C) 2013 Peter Miller
and that's the whole page bestie!! π this was explain_getrusage_or_die(3) from libexplain version 1.4, copyright (C) 2013 Peter Miller β go forth and get that resource usage, you absolute legend π¦β¨ periodt.
π¦ 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