explain_setpgid_or_die(3)

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

πŸ’– explain_setpgid_or_die(3) πŸ’–

okay bestie, welcome to the Library Functions Manual page for explain_setpgid_or_die(3) β€” yes that's the whole manual name, we're not being weird about it, it's just the vibe ✨


🌸 NAME 🌸

explain_setpgid_or_die β€” set process group and report errors 🫢


✨ SYNOPSIS ✨

#include <libexplain/setpgid.h>
void explain_setpgid_or_die(pid_t pid, pid_t pgid);
int explain_setpgid_on_error(pid_t pid, pid_t pgid);

πŸ’… DESCRIPTION πŸ’…

So the explain_setpgid_or_die function is literally just there to call the setpgid(2) system call. And if that goes badly? An explanation gets printed to stderr β€” grabbed straight from the explain_setpgid(3) function β€” and then the process terminates by calling exit(EXIT_FAILURE). no coming back from that one, bestie πŸ’€

Then there's explain_setpgid_on_error, which also calls the setpgid(2) system call. Same deal on failure: explanation printed to stderr, obtained from explain_setpgid(3). BUT β€” and this is the key difference, iykyk β€” this one still returns to the caller. she's giving graceful 🌈

  • pid β€” the pid, exactly as to be passed to the setpgid(2) system call. no edits, no remixing, just hand it over as-is πŸ’–
  • pgid β€” the pgid, exactly as to be passed to the setpgid(2) system call. same energy, character for character πŸŽ€

πŸ‘‘ RETURN VALUE πŸ‘‘

explain_setpgid_or_die only returns on success β€” peep setpgid(2) for more info on that. On failure? It prints an explanation and exits. It does not return. periodt.

explain_setpgid_on_error always returns the value returned by the wrapped setpgid(2) system call. always. every single time. πŸ¦‹


🌟 EXAMPLE 🌟

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

explain_setpgid_or_die(pid, pgid);

like... that's it. that's the whole thing. slay πŸ’…


πŸ”₯ SEE ALSO πŸ”₯


libexplain version 1.4 Copyright (C) 2011 Peter Miller


and that's a wrap on explain_setpgid_or_die(3) 🫢 this page came to you courtesy of libexplain version 1.4, copyright (C) 2011 Peter Miller β€” go forth and set those process groups, bestie, and may your stderr stay quiet πŸŒΈβœ¨πŸ’œ

πŸ“¦ where this page comes from