explain_pipe2(3)
π explain_pipe2 β the manual, but make it make sense π
okay bestie, gather round, because today we're talking about explain_pipe2(3) from the Library Functions Manual, and honestly? it's giving "your fave debugging bestie who never lets you down." π«Ά
β¨ NAME β¨
explain_pipe2 β it explains pipe2(2) errors. that's it. that's the job. and it does it so well. π
πΈ SYNOPSIS πΈ
#include <libexplain/pipe2.h>
const char *explain_pipe2(int *fildes, int flags);
const char *explain_errno_pipe2(int errnum, int *fildes, int flags);
void explain_message_pipe2(char *message, int message_size, int *fildes,
int flags);
void explain_message_errno_pipe2(char *message, int message_size, int
errnum, int *fildes, int flags);
four functions, all here to catch you when pipe2(2) does a little oopsie. π¦
π DESCRIPTION π
so like. these functions exist so you can get explanations for errors that the pipe2(2) system call throws back at you. no more squinting at errno like it owes you money. π
π explain_pipe2
const char *explain_pipe2(int *fildes, int flags);
the explain_pipe2 function is your go-to for getting an explanation of an error that pipe2(2) returned. the least the message will contain is the value of strerror(errno), but lowkey it usually does way better than that and tells you the actual underlying cause in more detail. no cap. β¨
the errno global variable is what gets used to grab the error value that needs decoding.
fildesβ the originalfildes, exactly as it was passed to thepipe2(2)system call. we don't touch it, we don't remix it, we just report it. πflagsβ the originalflags, exactly as passed to thepipe2(2)system call. same energy. π
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. so it will get overwritten by the next call to any libexplain function that shares this buffer β including calls from other threads. π
Note: this function is not thread safe, because it shares a return buffer across all threads, and lots of other functions in this library do the same thing. be aware, bestie. π
Example: this function is meant to be used in a fashion similar to the following example:
if (pipe2(fildes, flags) < 0)
{
fprintf(stderr, "%s\n", explain_pipe2(fildes, flags));
exit(EXIT_FAILURE);
}
and the above code example is available pre-packaged as the explain_pipe2_or_die(3) function. iconic behaviour, honestly. π
π explain_errno_pipe2
const char *explain_errno_pipe2(int errnum, int *fildes, int flags);
the explain_errno_pipe2 function also obtains an explanation of an error returned by the pipe2(2) system call. again, the least the message will contain is the value of strerror(errno), but usually it does much better and points at the underlying cause in more detail. we love a thorough queen. π
errnumβ the error value to be decoded, usually grabbed from theerrnoglobal variable right before this function gets called. this matters because if you need to run any code between the system call being explained and this function, you have to save it first β because a lot of libc functions will mess with the value oferrno. fr fr. β οΈfildesβ the originalfildes, exactly as passed to thepipe2(2)system call.flagsβ the originalflags, exactly as passed to thepipe2(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, and it will be overwritten by the next call to any libexplain function that shares this buffer, including other threads. π
Note: not thread safe. same reason as before β shared return buffer across all threads, and many other functions in this library share it too. π
Example: this function is intended to be used in a fashion similar to the following example:
if (pipe2(fildes, flags) < 0)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_pipe2(err, fildes,
flags));
exit(EXIT_FAILURE);
}
and yep, the above code example is available pre-packaged as the explain_pipe2_or_die(3) function. π
π¦ explain_message_pipe2
void explain_message_pipe2(char *message, int message_size, int *fildes,
int flags);
the explain_message_pipe2 function obtains an explanation of an error returned by the pipe2(2) system call. the least the message will contain is the value of strerror(errno), but usually it goes much harder and indicates the underlying cause in more detail. β¨
the errno global variable is what's used to obtain the error value to be decoded.
messageβ the location where the returned message gets stored. and here's the good part: if you supply a suitable message return buffer, this function is thread safe. slay. π₯message_sizeβ the size in bytes of the location where the returned message gets stored.fildesβ the originalfildes, exactly as passed to thepipe2(2)system call.flagsβ the originalflags, exactly as passed to thepipe2(2)system call.
Example: this function is intended to be used in a fashion similar to the following example:
if (pipe2(fildes, flags) < 0)
{
char message[3000];
explain_message_pipe2(message, sizeof(message), fildes,
flags);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
the above code example is available pre-packaged as the explain_pipe2_or_die(3) function. π
π§ explain_message_errno_pipe2
void explain_message_errno_pipe2(char *message, int message_size, int
errnum, int *fildes, int flags);
the explain_message_errno_pipe2 function obtains an explanation of an error returned by the pipe2(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. we stan a detailed explanation. πΈ
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. πfildesβ the originalfildes, exactly as passed to thepipe2(2)system call.flagsβ the originalflags, exactly as passed to thepipe2(2)system call.
Example: this function is intended to be used in a fashion similar to the following example:
if (pipe2(fildes, flags) < 0)
{
int err = errno;
char message[3000];
explain_message_errno_pipe2(message, sizeof(message), err,
fildes, flags);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
the above code example is available pre-packaged as the explain_pipe2_or_die(3) function. β
π SEE ALSO π
pipe2(2)β create pipeexplain_pipe2_or_die(3)β create pipe and report errors
go read them, bestie, they're part of the lore. π
π COPYRIGHT π
libexplain version 1.4 Copyright (C) 2013 Peter Miller
and that's the whole page, bestie β this was explain_pipe2(3) from the Library Functions Manual, brought to you by libexplain version 1.4, Β© 2013 Peter Miller. now go forth and let your pipes explain themselves. π
β¨π¦
π¦ 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) 2013 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms