explain_flock(3)
β¨ explain_flock(3) β¨
okay bestie so we're in the Library Functions Manual today and the star of the show is explain_flock(3) β the whole girlboss saga of explaining flock(2) errors π
πΈ NAME πΈ
explain_flock</p> β literally just explain flock(2) errors, that's it, that's the whole vibe π¦
β¨ SYNOPSIS β¨
#include <libexplain/flock.h>
const char *explain_flock(int fildes, int command);
const char *explain_errno_flock(int errnum, int fildes, int command);
void explain_message_flock(char *message, int message_size, int fildes,
int command);
void explain_message_errno_flock(char *message, int message_size, int
errnum, int fildes, int command);
π DESCRIPTION π
okay so these functions are your lil besties for getting explanations when the flock(2) system call comes back with an error π Like, instead of just "it broke", you get the actual tea about why.
π explain_flock
const char *explain_flock(int fildes, int command);
The explain_flock function gets you an explanation of an error returned by the flock(2) system call. The least the message will contain is the value of strerror(errno), but usually it does so much better and points at the underlying cause with way more detail. she ate π
The errno global variable is what gets used to obtain the error value to be decoded.
fildesβ the originalfildes, exactly as passed to theflock(2)system call. no notes.commandβ the originalcommand, exactly as passed to theflock(2)system call. also no notes.
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. so like. be aware bestie π«Ά
Example: This function is intended to be used in a fashion similar to the following example:
if (flock(fildes, command) < 0)
{
fprintf(stderr, "%s\n", explain_flock(fildes, command));
exit(EXIT_FAILURE);
}
The above code example is available preβpackaged as the explain_flock_or_die(3) function. iconic honestly β
π explain_errno_flock
const char *explain_errno_flock(int errnum, int fildes, int command);
The explain_errno_flock function gets you an explanation of an error returned by the flock(2) system call. The least the message will contain is the value of strerror(errno), but usually it does much better and indicates the underlying cause in more detail. yeah she's thorough like that π
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 grab it early, fr fr.fildesβ the originalfildes, exactly as passed to theflock(2)system call.commandβ the originalcommand, exactly as passed to theflock(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. π«
Example: This function is intended to be used in a fashion similar to the following example:
if (flock(fildes, command) < 0)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_flock(err, fildes,
command));
exit(EXIT_FAILURE);
}
The above code example is available preβpackaged as the explain_flock_or_die(3) function.
π¦ explain_message_flock
void explain_message_flock(char *message, int message_size, int fildes,
int command);
The explain_message_flock function gets you an explanation of an error returned by the flock(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. she's giving detail queen β¨
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. slay.message_sizeβ the size in bytes of the location in which to store the returned message.fildesβ the originalfildes, exactly as passed to theflock(2)system call.commandβ the originalcommand, exactly as passed to theflock(2)system call.
Example: This function is intended to be used in a fashion similar to the following example:
if (flock(fildes, command) < 0)
{
char message[3000];
explain_message_flock(message, sizeof(message), fildes,
command);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
The above code example is available preβpackaged as the explain_flock_or_die(3) function.
π§ explain_message_errno_flock
void explain_message_errno_flock(char *message, int message_size, int
errnum, int fildes, int command);
The explain_message_errno_flock function is used to obtain an explanation of an error returned by the flock(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. π
messageβ the location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe. we love a safe queen.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. (yes she said it again, it matters okay π)fildesβ the originalfildes, exactly as passed to theflock(2)system call.commandβ the originalcommand, exactly as passed to theflock(2)system call.
Example: This function is intended to be used in a fashion similar to the following example:
if (flock(fildes, command) < 0)
{
int err = errno;
char message[3000];
explain_message_errno_flock(message, sizeof(message), err,
fildes, command);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
The above code example is available preβpackaged as the explain_flock_or_die(3) function. periodt. π
π SEE ALSO π
flock(2)β apply or remove an advisory lock on an open fileexplain_flock_or_die(3)β apply or remove an advisory lock on an open file and report errors
iykyk π
π COPYRIGHT π
libexplain version 1.4 Copyright (C) 2009 Peter Miller
and that's the whole page bestie π this has been explain_flock(3) from the Library Functions Manual, brought to you by libexplain version 1.4, copyright (C) 2009 Peter Miller β go forth and lock your files responsibly, mwah π«Άβ¨
π¦ 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 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms