35#ifndef _UTILS_FD_UTILS_HXX_
36#define _UTILS_FD_UTILS_HXX_
52 uint8_t *dst =
static_cast<uint8_t *
>(buf);
55 ssize_t ret = ::read(fd, dst, size);
59 DIE(
"Unexpected EOF reading the config file.");
73 const uint8_t *dst =
static_cast<const uint8_t *
>(buf);
76 ssize_t ret = ::write(fd, dst, size);
80 DIE(
"Unexpected EOF writing the config file.");
#define ERRNOCHECK(where, x...)
Calls the function x, and if the return value is negative, prints errno as error message to stderr an...
#define DIE(MSG)
Unconditionally terminates the current process with a message.
static void optimize_socket_fd(int fd)
Optimizes the kernel settings like socket and TCP options for an fd that is an outgoing TCP socket.
static void repeated_read(int fd, void *buf, size_t size)
Performs a reliable read from the given FD.
static void optimize_tty_fd(int fd)
Sets the kernel settings like queuing and terminal settings for an fd that is an outgoing tty.
static void optimize_fd(int fd)
For an fd that is an outgoing link, detects what kind of file descriptor this is and calls the approp...
static void repeated_write(int fd, const void *buf, size_t size)
Performs a reliable write to the given FD.