explain_pclose_or_die(3)

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

✨ explain_pclose_or_die ✨

okay bestie, we're in section 3 of the Library Functions Manual and this one is literally about process I/O and reporting errors πŸ’– it's explain_pclose_or_die and she's here to hold your hand while you pclose(3). no cap.


🌸 NAME 🌸

explain_pclose_or_die β€” process I/O and report errors 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <libexplain/pclose.h>
int explain_pclose_or_die(FILE *fp);
int explain_pclose_success(FILE *fp);
void explain_pclose_success_or_die(FILE *fp);

like, three whole functions, all yours, all iconic πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

So these functions are your little helpers for waiting for a program to terminate, and then reporting the errors that the pclose(3) system call hands back. that's the whole vibe. πŸ’…

πŸ’œ explain_pclose_or_die

int explain_pclose_or_die(FILE *fp);

explain_pclose_or_die is the one you call when you wanna run the pclose(3) system call. And if it fails? bestie, an explanation gets printed to stderr, scooped straight out of explain_pclose(3), and then the process terminates by calling exit(EXIT_FAILURE). it's giving dramatic exit, fr fr 😭

You're meant to use it kinda like this:

int status = explain_pclose_or_die(fp);
  • fp β€” the fp, exactly as to be passed to the pclose(3) system call. no substitutions, no remixes, exact.

Returns:

  • This function only returns on success, see pclose(3) for more information. On failure, it prints an explanation and exits. periodt. πŸ’€

🌈 explain_pclose_success_or_die

void explain_pclose_success_or_die(FILE *);

explain_pclose_success_or_die is also used to call the pclose(3) system call. but she's pickier πŸ‘‘ on failure β€” and yes, that means any exit status other than EXIT_SUCCESS β€” an explanation gets printed to stderr, obtained from explain_pclose(3), and then the process terminates by calling exit(EXIT_FAILURE). she does not play. πŸ™ˆ

Intended usage, something like:

explain_pclose_success_or_die(fp);
  • fp β€” the fp, exactly as to be passed to the pclose(3) system call.

Returns:

  • This function only returns on success. On failure, it prints an explanation and exits.

⭐ explain_pclose_success

int explain_pclose_success(FILE *fp);

explain_pclose_success calls the pclose(3) system call too. on failure β€” again, including any exit status other than EXIT_SUCCESS β€” an explanation gets printed to stderr, obtained from explain_pclose(3). BUT, and this is the plot twist bestie: the printing of an error message does not also cause exit(2) to be called. she tells you, she doesn't take you out. main character energy that respects your autonomy. πŸ’…

Use it like:

int status = explain_pclose_success(command);
  • fp β€” the fp, exactly as to be passed to the pclose(3) system call.

Returns:

  • the value returned by the pclose(3) system call. In all cases other than EXIT_SUCCESS, an error message will also have been printed to stderr. so you will know. πŸ‘€

πŸ‘‘ SEE ALSO πŸ‘‘


libexplain version 1.4
Copyright (C) 2009 Peter Miller

and that's the whole page, bestie πŸŽ€ it's from libexplain version 1.4, Copyright (C) 2009 Peter Miller, filed under the Library Functions Manual, and the footer is just the title waving back at you β€” explain_pclose_or_die(3) β€” same as the top, because symmetry is iconic. iykyk πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from