EXPLAIN_SETRESGID_OR_DIE(3)

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

πŸ’– explain_setresgid_or_die β€” Library Functions Manual πŸ’–

okay bestie, welcome to explain_setresgid_or_die(3), the libexplain glow-up that lets you set your real / effective / saved group IDs and actually hear about it when it goes wrong instead of just… silently perishing. we love a communicative icon. 🫢


✨ NAME ✨

explain_setresgid_or_die β€” set r/e/s group ID and report errors


🌸 SYNOPSIS 🌸

#include <libexplain/setresgid.h>
void explain_setresgid_or_die(gid_t rgid, gid_t egid, gid_t sgid);
int explain_setresgid_on_error(gid_t rgid, gid_t egid, gid_t sgid);

πŸ¦‹ DESCRIPTION πŸ¦‹

so. the explain_setresgid_or_die function is the main character here β€” it calls the setresgid(2) system call for you. and if that call fails? it prints a whole explanation to stderr, snatched straight from the explain_setresgid(3) function, and then the process literally terminates by calling exit(EXIT_FAILURE). no cap, it does not come back. πŸ’€

meanwhile, explain_setresgid_on_error is the chiller sibling. it also calls the setresgid(2) system call, and on failure it also prints an explanation to stderr obtained from the explain_setresgid(3) function β€” but then it just… returns to the caller. it's giving emotionally available. πŸ™ˆ

now the arguments, one by one, no skipping:

  • rgid β€” the rgid, exactly as to be passed to the setresgid(2) system call.
  • egid β€” the egid, exactly as to be passed to the setresgid(2) system call.
  • sgid β€” the sgid, exactly as to be passed to the setresgid(2) system call.

like, exactly exactly. don't get cute with them. πŸ’…


πŸ‘‘ RETURN VALUE πŸ‘‘

  • the explain_setresgid_or_die function only returns on success β€” see setresgid(2) for more info on what that success even means. on failure it prints an explanation and exits. it does not return. periodt. 😭
  • the explain_setresgid_on_error function always returns the value return by the wrapped setresgid(2) system call.

🌈 EXAMPLE 🌈

the explain_setresgid_or_die function is intended to be used in a fashion similar to the following example:

explain_setresgid_or_die(rgid, egid, sgid);

look at that. one line. flawless. iconic. πŸŽ€


πŸ’œ SEE ALSO πŸ’œ


libexplain version 1.4 Copyright (C) 2012 Peter Miller

and that's the whole page, bestie πŸ’– this was explain_setresgid_or_die(3) from the Library Functions Manual β€” libexplain version 1.4, Copyright (C) 2012 Peter Miller, and yes the footer is slaying just as hard as the header. mwah. πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from