explain_wait3(3)
π NAME π
okay so this whole page is about explain_wait3, and its one job is literally explaining wait3(2) errors. that's it. that's the vibe. π
β¨ SYNOPSIS β¨
bestie, here's the roster of functions you're getting, and yes you gotta include the header first:
#include <libexplain/wait3.h>
const char *explain_wait3(int *status, int options, struct rusage *rusage);
const char *explain_errno_wait3(int errnum, int *status, int options, struct rusage *rusage);
void explain_message_wait3(char *message, int message_size, int *status, int options, struct rusage *rusage);
void explain_message_errno_wait3(char *message, int message_size, int errnum, int *status, int options, struct rusage *rusage);
π DESCRIPTION π
so these functions? they're your little translator besties for errors that come back from the wait3(2) system call. instead of you squinting at a cryptic error, they hand you a whole explanation. iconic behavior honestly. π«Ά
πΈ explain_wait3 πΈ
const char *explain_wait3(int *status, int options, struct rusage *rusage);
the explain_wait3 function gets you an explanation of an error that came back from the wait3(2) system call. the absolute bare minimum it'll give you is the value of strerror(errno), but ngl it usually does way better than that and points at the actual underlying cause in more detail. slay. β¨
it pulls the error value it's gonna decode from the errno global variable.
you're meant to use this one like, basically like this:
int pid = wait3(status, options, rusage);
if (pid < 0)
{
fprintf(stderr, "%s\n", explain_wait3(status, options, rusage));
exit(EXIT_FAILURE);
}
statusβ the originalstatus, exactly as passed to thewait3(2)system call. no edits, no glow-ups, just as-is.optionsβ the originaloptions, exactly as passed to thewait3(2)system call.rusageβ the originalrusage, exactly as passed to thewait3(2)system call.
Returns:
- the message explaining the error. lowkey important: this message buffer is shared by all the libexplain functions that don't supply a buffer in their argument list. so the next call to any libexplain function that shares this buffer will overwrite it β including calls from 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 do the same thing. so, like, be careful out there.
π¦ explain_errno_wait3 π¦
const char *explain_errno_wait3(int errnum, int *status, int options, struct rusage *rusage);
the explain_errno_wait3 function gets you an explanation of an error returned by the wait3(2) system call. least it'll give you is the value of strerror(errnum), but usually it does so much better and tells you the underlying cause in more detail. periodt.
use it like this, bestie:
int pid = wait3(status, options, rusage);
if (pid < 0)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_wait3(err, status, options,
rusage));
exit(EXIT_FAILURE);
}
errnumβ the error value to be decoded, usually grabbed from theerrnoglobal variable right before you call this function. you need to do that if there's any code running between the system call you're explaining and this function, because a whole bunch of libc functions will change the value oferrnoon you. sneaky. πstatusβ the originalstatus, exactly as passed to thewait3(2)system call.optionsβ the originaloptions, exactly as passed to thewait3(2)system call.rusageβ the originalrusage, exactly as passed to thewait3(2)system call.
Returns:
- the message explaining the error. and again, this message buffer is shared by all libexplain functions that don't supply a buffer in their argument list, so the next call to any libexplain function sharing this buffer will overwrite it β other threads included.
Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library do too.
π§ explain_message_wait3 π§
void explain_message_wait3(char *message, int message_size, int *status, int options, struct rusage *rusage);
the explain_message_wait3 function may be used to obtain an explanation of an error returned by the wait3(2) system call. minimum content is the value of strerror(errno), but bestie, usually it goes way harder and shows the underlying cause in more detail. π₯
it uses the errno global variable to get the error value that needs decoding.
use it like:
int pid = wait3(status, options, rusage);
if (pid < 0)
{
char message[3000];
explain_message_wait3(message, sizeof(message),
status, options, rusage);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
messageβ the location where the returned message gets stored. and here's the glow-up: if you supply a suitable message return buffer, this function is thread safe. we love that for you. πmessage_sizeβ the size in bytes of the location where the returned message gets stored.statusβ the originalstatus, exactly as passed to thewait3(2)system call.optionsβ the originaloptions, exactly as passed to thewait3(2)system call.rusageβ the originalrusage, exactly as passed to thewait3(2)system call.
π explain_message_errno_wait3 π
void explain_message_errno_wait3(char *message, int message_size, int errnum, int *status, int options, struct rusage *rusage);
the explain_message_errno_wait3 function may be used to obtain an explanation of an error returned by the wait3(2) system call. the least the message will contain is the value of strerror(errnum), but usually it does much better and indicates the underlying cause in more detail. she ate. π
use it like this:
int pid = wait3(status, options, rusage);
if (pid < 0)
{
int err = errno;
char message[3000];
explain_message_errno_wait3(message, sizeof(message), err,
status, options, rusage);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
messageβ the location where the returned message gets stored. if a suitable message return buffer is supplied, this function is thread safe. πmessage_sizeβ the size in bytes of the location where the returned message gets stored.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 being explained and this function, because many libc functions will alter the value oferrno. no cap.statusβ the originalstatus, exactly as passed to thewait3(2)system call.optionsβ the originaloptions, exactly as passed to thewait3(2)system call.rusageβ the originalrusage, exactly as passed to thewait3(2)system call.
π SEE ALSO π
wait3(2)β wait for process to change stateexplain_wait3_or_die(3)β wait for process to change state and report errors
π COPYRIGHT π
libexplain version 1.4 Copyright (C) 2008 Peter Miller
and that's the whole page bestie, mwah π
β¨ the explain_wait3(3) manual page, version 1.4 energy, dated all the way back to the 2008 copyright era β she's vintage and she's still iconic, fr fr ππ¦π
π¦ 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