explain_write(3)
π explain_write(3) π
okay bestie, listen up β this is the manual page for explain_write, living in section 3 of the Library Functions Manual. it's giving "your write(2) call failed and you need to know WHY" energy, and honestly? iconic. π
β¨ NAME β¨
explain_write β explain write(2) errors π«Ά
β¨ SYNOPSIS β¨
#include <libexplain/write.h>
const char *explain_write(int fildes, const void *data, long data_size);
const char *explain_errno_write(int errnum, int fildes, const void
*data, long data_size);
void explain_message_write(char *message, int message_size, int fildes,
const void *data, long data_size);
void explain_message_errno_write(char *message, int message_size, int
errnum, int fildes, const void *data, long data_size);
β¨ DESCRIPTION β¨
so these functions are your little helpers for getting explanations of write(2) errors. π
πΈ explain_write
const char *explain_write(int fildes, const void *data, long data_size);
the explain_write function gets you a human readable explanation of what went wrong in a write(2) system call. the least the message will contain is the value of strerror(errno), but usually it does so much better and tells you the underlying cause in way more detail. slay.
the error number gets picked up from the errno global variable. periodt.
this function is meant to be used in a fashion similar to the following example:
sszie_t n = write(fd, data, data_size);
if (n < 0)
{
fprintf(stderr, '%s0, explain_read(fd, data, data_size));
exit(EXIT_FAILURE);
}
fildesβ the original fildes, exactly as passed to thewrite(2)system call. no cap.dataβ the original data, exactly as passed to thewrite(2)system call.data_sizeβ the original data_size, exactly as passed to thewrite(2)system call.
Returns: the message explaining the error. π₯Ί this message buffer is shared by all libexplain functions that don't supply a buffer in their argument list. it will get overwritten by the next call to any libexplain function that shares this buffer β including other threads. so like, don't get attached to it bestie.
Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. π
πΈ explain_errno_write
const char *explain_errno_write(int errnum, int fildes, const void
*data, long data_size);
the explain_errno_write function gets you a human readable explanation of what went wrong in a write(2) system call. the least the message will contain is the value of strerror(errnum), but usually it does way better and points at the underlying cause in more detail. β¨
this function is meant to be used in a fashion similar to the following example:
sszie_t n = write(fd, data, data_size);
if (n < 0)
{
int err = errno;
fprintf(stderr, '%s0, explain_errno_read(errnum, fd, data,
data_size));
exit(EXIT_FAILURE);
}
errnumβ the error value to be decoded, usually obtain 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. πfildesβ the original fildes, exactly as passed to thewrite(2)system call.dataβ the original data, exactly as passed to thewrite(2)system call.data_sizeβ the original data_size, exactly as passed to thewrite(2)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.
πΈ explain_message_write
void explain_message_write(char *message, int message_size, int fildes,
const void *data, long data_size);
the explain_message_write function gets you a human readable explanation of what went wrong in a write(2) 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 error number will be picked up from the errno global variable.
this function is meant to be used in a fashion similar to the following example:
sszie_t n = write(fd, data, data_size);
if (n < 0)
{
char message[3000];
explain_message_read(message, sizeof(message), fd, data,
data_size));
fprintf(stderr, '%s0, message);
exit(EXIT_FAILURE);
}
messageβ the location in which to store the returned message. because a message return buffer has been supplied, this function is thread safe. πmessage_sizeβ the size in bytes of the location in which to store the returned message.fildesβ the original fildes, exactly as passed to thewrite(2)system call.dataβ the original data, exactly as passed to thewrite(2)system call.data_sizeβ the original data_size, exactly as passed to thewrite(2)system call.
Note: given a suitably thread safe buffer, this function is thread safe. we love to see it. π«Ά
πΈ explain_message_errno_write
void explain_message_errno_write(char * message, int message_size, int
errnum, int fildes, const void *data, long data_size);
the explain_message_errno_write function gets you a human readable explanation of what went wrong in a write(2) system call. the least the message will contain is the value of strerror(errnum), but usually it will do much better, and indicate the underlying cause in more detail. π₯
this function is meant to be used in a fashion similar to the following example:
sszie_t n = write(fd, data, data_size);
if (n < 0)
{
int err = errno;
char message[3000];
explain_message_errno_read(message, sizeof(message), errno,
fd, data, data_size));
fprintf(stderr, '%s0, message);
exit(EXIT_FAILURE);
}
messageβ the location in which to store the returned message. because a message return buffer has been 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 obtain 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. πfildesβ the original fildes, exactly as passed to thewrite(2)system call.dataβ the original data, exactly as passed to thewrite(2)system call.data_sizeβ the original data_size, exactly as passed to thewrite(2)system call.
Note: given a suitably thread safe buffer, this function is thread safe.
β¨ COPYRIGHT β¨
libexplain version 1.4 Copyright (C) 2008 Peter Miller
β¨ AUTHOR β¨
Written by Peter Miller <pmiller@opensource.org.au> π§
and that's the whole page bestie, no notes. this was libexplain version 1.4, copyright Β© 2008 Peter Miller, written by Peter Miller himself β go read your errors, stay thread safe, and hydrate. πβ¨πΈππ¦π
π«Άππβππ§π
π¦ 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) 2008, 2009, 2011 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms