EXPLAIN_GETRUSAGE_OR_DIE(3)

πŸ“¦
version 1.4.D001 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

✨ 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 β€” the who, exactly as to be passed to the getrusage(2) system call. like, don't get creative with it, pass it through as-is πŸ’«
  • usage β€” the usage, exactly as to be passed to the getrusage(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 🌈

iykyk, the whole little family πŸ’œ


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