explain_wait(3)

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

πŸ’– explain_wait(3) πŸ’–

okay bestie, gather round, we're reading a manual page from the Library Functions Manual and honestly? it's giving "I explain wait(2) errors and I do it flawlessly". this is explain_wait, and she ate. πŸŽ€


✨ NAME ✨

explain_wait β€” explain wait(2) errors πŸ’…


🌸 SYNOPSIS 🌸

#include <libexplain/wait.h>
const char *explain_wait(int *status);
const char *explain_errno_wait(int errnum, int *status);
void explain_message_wait(char *message, int message_size, int *status);
void explain_message_errno_wait(char *message, int message_size, int errnum, int *status);

πŸ¦‹ DESCRIPTION πŸ¦‹

so these functions? they're the whole point. you use them to get explanations for errors returned by the wait(2) system call. like, an actual human-readable reason instead of you staring at errno like πŸ‘οΈπŸ‘„πŸ‘οΈ


πŸ’œ explain_wait

const char *explain_wait(int *status);

explain_wait is the one you call to obtain an explanation of an error returned by the wait(2) system call. the absolute least the message will contain is the value of strerror(errno), but usually it will do much better and point at the underlying cause in more detail. lowkey overachiever behavior, we love that for her. ✨

the errno global variable is what she uses to obtain the error value to be decoded.

this function is intended to be used in a fashion similar to the following example:

if (wait(status) < 0)
{
    fprintf(stderr, "%s\n", explain_wait(status));
    exit(EXIT_FAILURE);
}
  • status β€” the original status, exactly as passed to the wait(2) system call.

Returns:

the message explaining the error. heads up though: this message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. it will be overwritten by the next call to any libexplain function which shares this buffer, including other threads. so don't get attached. 😭

Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. periodt.

🫢 explain_errno_wait

const char *explain_errno_wait(int errnum, int *status);

explain_errno_wait is used to obtain an explanation of an error returned by the wait(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. no cap. πŸ’…

this function is intended to be used in a fashion similar to the following example:

if (wait(status) < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_wait(err, status));
    exit(EXIT_FAILURE);
}
  • errnum β€” the error value to be decoded, usually obtained from the errno global 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 of errno. yes bestie, they're messy like that. πŸ™ˆ
  • status β€” the original status, exactly as passed to the wait(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. so like, screenshot it or it didn't happen. 😭

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_wait

void explain_message_wait(char *message, int message_size, int *status);

explain_message_wait may be used to obtain an explanation of an error returned by the wait(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. iconic. ✨

the errno global variable will be used to obtain the error value to be decoded.

this function is intended to be used in a fashion similar to the following example:

if (wait(status) < 0)
{
    char message[3000];
    explain_message_wait(message, sizeof(message), status);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}
  • message β€” the location in which to store the returned message. if a suitable message return buffer is supplied, this function is thread safe. πŸ‘‘ you supply the buffer, you get thread safety. main character energy fr fr.
  • message_size β€” the size in bytes of the location in which to store the returned message.
  • status β€” the original status, exactly as passed to the wait(2) system call.

⭐ explain_message_errno_wait

void explain_message_errno_wait(char *message, int message_size, int errnum, int *status);

explain_message_errno_wait may be used to obtain an explanation of an error returned by the wait(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. she's thorough, okay?? πŸŽ€

this function is intended to be used in a fashion similar to the following example:

if (wait(status) < 0)
{
    int err = errno;
    char message[3000];
    explain_message_errno_wait(message, sizeof(message), err, status);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}
  • 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 the errno global 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 of errno. yes, again. they do that. every time. πŸ’€
  • status β€” the original status, exactly as passed to the wait(2) system call.

πŸ‘‘ SEE ALSO πŸ‘‘


  • libexplain version 1.4
  • Copyright (C) 2008 Peter Miller

and that's the whole page bestie, you made it to the end πŸ¦‹ go forth and explain your errors, you absolute legend πŸ’–

libexplain version 1.4 Β· Copyright (C) 2008 Peter Miller Β· explain_wait(3) β€” mwah, bye!! πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from