explain_fileno(3)
π explain_fileno(3) π
okay bestie, gather round, we're doing explain_fileno(3) from the Library Functions Manual and it's genuinely so useful. This is the glow-up page for all the fileno(3) error-explaining functions in libexplain, and I'm gonna walk you through every single one. no skips. periodt. β¨
πΈ NAME πΈ
explain_fileno β explain fileno(3) errors π
like, it literally explains the errors. that's the whole job. iconic.
π SYNOPSIS π
#include <libexplain/fileno.h>
const char *explain_fileno(FILE *fp);
const char *explain_errno_fileno(int errnum, FILE *fp);
void explain_message_fileno(char *message, int message_size, FILE *fp);
void explain_message_errno_fileno(char *message, int message_size, int errnum, FILE *fp);
four functions. four besties. each one handles the error-explaining vibe a lil differently, and honestly? slay. π¦
β¨ DESCRIPTION β¨
so, these functions may be used to obtain explanations for errors returned by the fileno(3) system call. that's the whole plot. no cap. π
π« explain_fileno
const char *explain_fileno(FILE *fp);
The explain_fileno function is used to obtain an explanation of an error returned by the fileno(3) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. like, it overdelivers. main character energy fr fr. π
The errno global variable will be used to obtain the error value to be decoded.
fpβ The original fp, exactly as passed to thefileno(3)system call. yes, the exact same one. don't be out here inventing new ones. π
Returns:
The message explaining the error. This message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. This will be overwritten by the next call to any libexplain function which shares this buffer, including other threads.
β οΈ Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. so like, if you're threading, know that. it's giving "borrowed your hoodie and gave it back different". π
Example: This function is intended to be used in a fashion similar to the following example:
if (fileno(fp) < 0)
{
fprintf(stderr, "%s\n", explain_fileno(fp));
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_fileno_or_die(3) function. so if you're lazy (valid), there's a shortcut. π
π explain_errno_fileno
const char *explain_errno_fileno(int errnum, FILE *fp);
The explain_errno_fileno function is used to obtain an explanation of an error returned by the fileno(3) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. same energy, different signature. β¨
errnumβ The error value to be decoded, usually obtained from theerrnoglobal variable just before this function is called. This is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value oferrno. yes bestie,errnois fragile. grab it fast or it's gone. π«Άfpβ The original fp, exactly as passed to thefileno(3)system call.
Returns:
The message explaining the error. This message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. This will be overwritten by the next call to any libexplain function which shares this buffer, including other threads.
β οΈ Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library.
Example: This function is intended to be used in a fashion similar to the following example:
if (fileno(fp) < 0)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_fileno(err, fp));
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_fileno_or_die(3) function. π
π¦ explain_message_fileno
void explain_message_fileno(char *message, int message_size, FILE *fp);
The explain_message_fileno function is used to obtain an explanation of an error returned by the fileno(3) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. β¨
The errno global variable will be used to obtain the error value to be decoded.
messageβ The location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe. ooh she's responsible. we love a buffer-owning queen. πmessage_sizeβ The size in bytes of the location in which to store the returned message.fpβ The original fp, exactly as passed to thefileno(3)system call.
Example: This function is intended to be used in a fashion similar to the following example:
if (fileno(fp) < 0)
{
char message[3000];
explain_message_fileno(message, sizeof(message), fp);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_fileno_or_die(3) function. π
π§ explain_message_errno_fileno
void explain_message_errno_fileno(char *message, int message_size, int errnum, FILE *fp);
The explain_message_errno_fileno function is used to obtain an explanation of an error returned by the fileno(3) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. the full combo meal, no substitutions. π
messageβ The location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe.message_sizeβ The size in bytes of the location in which to store the returned message.errnumβ The error value to be decoded, usually obtained from theerrnoglobal variable just before this function is called. This is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value oferrno. yes, again,errnowill get sniped if you sleep on it. πfpβ The original fp, exactly as passed to thefileno(3)system call.
Example: This function is intended to be used in a fashion similar to the following example:
if (fileno(fp) < 0)
{
int err = errno;
char message[3000];
explain_message_errno_fileno(message, sizeof(message), err, fp);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
The above code example is available pre-packaged as the explain_fileno_or_die(3) function. πΈ
π SEE ALSO π
fileno(3)β check and reset stream statusexplain_fileno_or_die(3)β check and reset stream status and report errors
go read those too bestie, they're part of the lore. π
π COPYRIGHT π
libexplainversion1.4- Copyright (C) 2009 Peter Miller
and that's the whole page!! π«Ά thanks for reading all the way to the end, you're literally the best. this was explain_fileno(3), part of the Library Functions Manual, libexplain version 1.4, Copyright (C) 2009 Peter Miller, and yes the footer says explain_fileno(3) one more time because she loves a grand entrance and an even grander exit. bye bestie, go explain some errors!! πβ¨ππ
π¦ 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) 2009-2011 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms