explain_tcsendbreak(3)

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

✨ NAME ✨

explain_tcsendbreak β€” bestie, this is the glow-up that explains your tcsendbreak(3) errors πŸ’…

So like, you called tcsendbreak(3) (it's in the Library Functions Manual, section 3, iykyk) and it flopped. This little libexplain page is here to tell you why it flopped, in actual words, not just a sad number. 🫢


🌸 SYNOPSIS 🌸

#include <libexplain/tcsendbreak.h>
const char *explain_tcsendbreak(int fildes, int duration);
const char *explain_errno_tcsendbreak(int errnum, int fildes, int duration);
void explain_message_tcsendbreak(char *message, int message_size, int fildes, int duration);
void explain_message_errno_tcsendbreak(char *message, int message_size, int errnum, int fildes, int duration);

πŸ’– DESCRIPTION πŸ’–

Okay so these functions are your error-translator besties β€” you use them to get actual explanations for errors that come back from the tcsendbreak(3) system call. No more staring at a bare errno like πŸ‘οΈπŸ‘„πŸ‘οΈ.


πŸŽ€ explain_tcsendbreak

const char *explain_tcsendbreak(int fildes, int duration);

The explain_tcsendbreak function gets you an explanation of an error that came back from the tcsendbreak(3) system call. The bare minimum the message will contain is the value of strerror(errno) β€” but honestly? Usually it does so much better than that, and it points at the actual underlying cause in way more detail. It's giving detective energy fr fr πŸ”

The errno global variable is what it uses to grab the error value it's gonna decode. (No passing it in, it just reads the global. Iconic but also, watch out, see the note below.)

  • fildes β€” the original fildes, exactly as passed to the tcsendbreak(3) system call. Don't get creative with it, it wants the real one.
  • duration β€” the original duration, exactly as passed to the tcsendbreak(3) system call. Same deal.

Returns:

The message explaining the error. πŸ’Œ Heads up though: 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. It's one communal water bottle, basically. 🚰

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

Example: This function is meant to be used in a fashion similar to the following example:

if (tcsendbreak(fildes, duration) < 0)
{
    fprintf(stderr, "%s\n", explain_tcsendbreak(fildes, duration));
    exit(EXIT_FAILURE);
}

The above code example is available pre-packaged as the explain_tcsendbreak_or_die(3) function. Slay, no need to write it yourself. ✨


πŸ¦‹ explain_errno_tcsendbreak

const char *explain_errno_tcsendbreak(int errnum, int fildes, int duration);

The explain_errno_tcsendbreak function gets you an explanation of an error that came back from the tcsendbreak(3) system call. Again, the least the message will contain is the value of strerror(errno), but usually it does way better and tells you the underlying cause in more detail. πŸ’…

  • errnum β€” the error value to be decoded, usually grabbed from the errno global variable just before this function is called. This is necessary if you need to run any code between the system call being explained and this function β€” because a lot of libc functions will mess with the value of errno. So like, snapshot it first, bestie. πŸ“Έ
  • fildes β€” the original fildes, exactly as passed to the tcsendbreak(3) system call.
  • duration β€” the original duration, exactly as passed to the tcsendbreak(3) system call.

Returns:

The message explaining the error. Same shared-buffer situation: this message buffer is shared by all libexplain functions which don't supply a buffer in their argument list, and it gets overwritten by the next call to any libexplain function sharing 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.

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

if (tcsendbreak(fildes, duration) < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_tcsendbreak(err, fildes, duration));
    exit(EXIT_FAILURE);
}

The above code example is available pre-packaged as the explain_tcsendbreak_or_die(3) function. 🎁


πŸ’œ explain_message_tcsendbreak

void explain_message_tcsendbreak(char *message, int message_size, int fildes, int duration);

The explain_message_tcsendbreak function is used to obtain an explanation of an error returned by the tcsendbreak(3) 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. πŸ‘‘

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

  • message β€” the location in which to store the returned message. Here's the cute part: if you supply a suitable message return buffer, this function is thread safe. You bring your own cup, you don't share. πŸ₯€
  • message_size β€” the size in bytes of the location in which to store the returned message.
  • fildes β€” the original fildes, exactly as passed to the tcsendbreak(3) system call.
  • duration β€” the original duration, exactly as passed to the tcsendbreak(3) system call.

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

if (tcsendbreak(fildes, duration) < 0)
{
    char message[3000];
    explain_message_tcsendbreak(message, sizeof(message), fildes, duration);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

The above code example is available pre-packaged as the explain_tcsendbreak_or_die(3) function. 🌟


🧚 explain_message_errno_tcsendbreak

void explain_message_errno_tcsendbreak(char *message, int message_size, int errnum, int fildes, int duration);

The explain_message_errno_tcsendbreak function is used to obtain an explanation of an error returned by the tcsendbreak(3) 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. The full combo meal, if you will. πŸ“

  • 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.
  • fildes β€” the original fildes, exactly as passed to the tcsendbreak(3) system call.
  • duration β€” the original duration, exactly as passed to the tcsendbreak(3) system call.

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

if (tcsendbreak(fildes, duration) < 0)
{
    int err = errno;
    char message[3000];
    explain_message_errno_tcsendbreak(message, sizeof(message), err, fildes, duration);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

The above code example is available pre-packaged as the explain_tcsendbreak_or_die(3) function. πŸŽ€


🌈 SEE ALSO 🌈


This is libexplain version 1.4, and it's Copyright (C) 2009 Peter Miller. Respect the elders, they ate. πŸ™‡β€β™€οΈ


And that's the whole page, bestie β€” explain_tcsendbreak(3), from the Library Functions Manual, written by Peter Miller in 2009 and shipped as libexplain version 1.4. Go forth and decode your errnos. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from