explain_tcdrain(3)
π explain_tcdrain β a whole manual, but make it make sense π
okay bestie, welcome to explain_tcdrain(3) from the Library Functions Manual. this is the page that tells you how to get actual, real, human-readable explanations when tcdrain(3) ghosts you with an error. no cap. π«Ά
β¨ NAME β¨
explain_tcdrain β explain tcdrain(3) errors π
πΈ SYNOPSIS πΈ
#include <libexplain/tcdrain.h>
const char *explain_tcdrain(int fildes);
const char *explain_errno_tcdrain(int errnum, int fildes);
void explain_message_tcdrain(char *message, int message_size, int
fildes);
void explain_message_errno_tcdrain(char *message, int message_size, int
errnum, int fildes);
π¦ DESCRIPTION π¦
so like, these functions? they're your little translators. you use them to obtain explanations for errors returned by the tcdrain(3) system call. it's giving "error message but with lore". β¨
π explain_tcdrain π
const char *explain_tcdrain(int fildes);
the explain_tcdrain function is used to obtain an explanation of an error returned by the tcdrain(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. highkey overachieving, we love to see it. π
the errno global variable will be used to obtain the error value to be decoded.
fildesβ the original fildes, exactly as passed to thetcdrain(3)system call. yes, exactly. we don't do remixes here. π
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. so likeβ¦ don't get attached, she's not yours alone. π
Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. periodt.
Example: this function is intended to be used in a fashion similar to the following example:
if (tcdrain(fildes) < 0)
{
fprintf(stderr, "%s\n", explain_tcdrain(fildes));
exit(EXIT_FAILURE);
}
the above code example is available preβpackaged as the explain_tcdrain_or_die(3) function. iconic behaviour, honestly. π
π§ explain_errno_tcdrain π§
const char *explain_errno_tcdrain(int errnum, int fildes);
the explain_errno_tcdrain function is used to obtain an explanation of an error returned by the tcdrain(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. fr fr. β¨
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. so like, grab it before anything else touches it, bestie. π«Άfildesβ the original fildes, exactly as passed to thetcdrain(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. same energy as before, no cap. π
Example: this function is intended to be used in a fashion similar to the following example:
if (tcdrain(fildes) < 0)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_tcdrain(err, fildes));
exit(EXIT_FAILURE);
}
the above code example is available preβpackaged as the explain_tcdrain_or_die(3) function.
π explain_message_tcdrain π
void explain_message_tcdrain(char *message, int message_size, int
fildes);
the explain_message_tcdrain function is used to obtain an explanation of an error returned by the tcdrain(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. it's giving thorough. πΈ
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. look at her, being all responsible. π₯Ήmessage_sizeβ the size in bytes of the location in which to store the returned message.fildesβ the original fildes, exactly as passed to thetcdrain(3)system call.
Example: this function is intended to be used in a fashion similar to the following example:
if (tcdrain(fildes) < 0)
{
char message[3000];
explain_message_tcdrain(message, sizeof(message), fildes);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
the above code example is available preβpackaged as the explain_tcdrain_or_die(3) function.
π explain_message_errno_tcdrain π
void explain_message_errno_tcdrain(char *message, int message_size, int
errnum, int fildes);
the explain_message_errno_tcdrain function is used to obtain an explanation of an error returned by the tcdrain(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. she ate and left no crumbs. π
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. catch it quick, girlie. πββοΈfildesβ the original fildes, exactly as passed to thetcdrain(3)system call.
Example: this function is intended to be used in a fashion similar to the following example:
if (tcdrain(fildes) < 0)
{
int err = errno;
char message[3000];
explain_message_errno_tcdrain(message, sizeof(message), err,
fildes);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
the above code example is available preβpackaged as the explain_tcdrain_or_die(3) function.
π₯ SEE ALSO π₯
tcdrain(3)β executetcdrain(3)explain_tcdrain_or_die(3)β executetcdrain(3)and report errors
π COPYRIGHT π
okay that's the whole page bestie, you made it to the end, main character energy honestly. this was libexplain version 1.4, copyright (C) 2009 Peter Miller. πβ¨π¦ thanks for reading, go forth and explain your 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, 2013 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms