explain_tcsetattr(3)

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

πŸ’– explain_tcsetattr β€” like, the manual page, but make it make sense πŸ’–

okay bestie, welcome to explain_tcsetattr(3) from the Library Functions Manual ✨ this is the little corner of libexplain that tells you why your terminal-attribute-setting call went sideways, and I'm gonna walk you through every single bit of it. no cap. 🫢


✨ NAME ✨

explain_tcsetattr β€” explain tcsetattr(3) errors πŸ’…


🌸 SYNOPSIS 🌸

#include <libexplain/tcsetattr.h>
const char *explain_tcsetattr(int fildes, int options, const struct
termios *data);
const char *explain_errno_tcsetattr(int errnum, int fildes, int options,
const struct termios *data);
void explain_message_tcsetattr(char *message, int message_size, int
fildes, int options, const struct termios *data);
void explain_message_errno_tcsetattr(char *message, int message_size,
int errnum, int fildes, int options, const struct termios *data);

four whole functions, all yours, all adorable πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

so, these functions? they're here to hand you explanations for errors that come back from the tcsetattr(3) system call. like, actual reasons. not just vibes.


πŸ‘‘ explain_tcsetattr

const char *explain_tcsetattr(int fildes, int options, const struct
termios *data);

the explain_tcsetattr function is what you call to get an explanation of an error returned by the tcsetattr(3) system call. the 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 way more detail. it's giving overachiever, and we love that. πŸ”₯

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

  • fildes β€” the original fildes, exactly as passed to the tcsetattr(3) system call. no edits, no glow-up, exactly as-is.
  • options β€” the original options, exactly as passed to the tcsetattr(3) system call.
  • data β€” the original data, exactly as passed to the tcsetattr(3) 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. it will be overwritten by the next call to any libexplain function which shares this buffer, including other threads. so like… screenshot it or copy it, don't just stare at it. 😭

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

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

if (tcsetattr(fildes, options, data) < 0)
{
    fprintf(stderr, "%s\n", explain_tcsetattr(fildes, options,
    data));
    exit(EXIT_FAILURE);
}

the above code example is available pre‐packaged as the explain_tcsetattr_or_die(3) function. it's literally the same thing but already wrapped for you, iconic. πŸ’–


🌈 explain_errno_tcsetattr

const char *explain_errno_tcsetattr(int errnum, int fildes, int options,
const struct termios *data);

the explain_errno_tcsetattr function is used to obtain an explanation of an error returned by the tcsetattr(3) 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. same energy as before, just with the errno handed to it directly. ✨

  • 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. like, errno is fragile bestie, it gets overwritten fast. πŸ™ˆ
  • fildes β€” the original fildes, exactly as passed to the tcsetattr(3) system call.
  • options β€” the original options, exactly as passed to the tcsetattr(3) system call.
  • data β€” the original data, exactly as passed to the tcsetattr(3) 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 (tcsetattr(fildes, options, data) < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_tcsetattr(err, fildes,
    options, data));
    exit(EXIT_FAILURE);
}

the above code example is available pre‐packaged as the explain_tcsetattr_or_die(3) function. πŸŽ€


🧚 explain_message_tcsetattr

void explain_message_tcsetattr(char *message, int message_size, int
fildes, int options, const struct termios *data);

the explain_message_tcsetattr function is used to obtain an explanation of an error returned by the tcsetattr(3) 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.

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

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

if (tcsetattr(fildes, options, data) < 0)
{
    char message[3000];
    explain_message_tcsetattr(message, sizeof(message), fildes,
    options, data);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

the above code example is available pre‐packaged as the explain_tcsetattr_or_die(3) function. πŸ’œ


⭐ explain_message_errno_tcsetattr

void explain_message_errno_tcsetattr(char *message, int message_size,
int errnum, int fildes, int options, const struct termios *data);

the explain_message_errno_tcsetattr function is used to obtain an explanation of an error returned by the tcsetattr(3) 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.
  • 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 tcsetattr(3) system call.
  • options β€” the original options, exactly as passed to the tcsetattr(3) system call.
  • data β€” the original data, exactly as passed to the tcsetattr(3) system call.

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

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

the above code example is available pre‐packaged as the explain_tcsetattr_or_die(3) function. 🌟


πŸ’« SEE ALSO πŸ’«


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

okay that's the whole page, you absolute legend, go forth and set your terminal attributes with confidence πŸ¦‹βœ¨ libexplain version 1.4, copyright (C) 2009 Peter Miller, and yes this is the explain_tcsetattr(3) page from the Library Functions Manual β€” mwah, take care bestie πŸ’–πŸ’…πŸŒˆ

πŸ“¦ where this page comes from