1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 02:37:42 +00:00

LibCore: Add syscall wrappers for tcgetattr() and tcsetattr()

This commit is contained in:
Andreas Kling 2021-11-29 23:28:10 +01:00
parent 2b0c2360bb
commit 612eafea2c
2 changed files with 19 additions and 0 deletions

View file

@ -13,6 +13,7 @@
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <termios.h>
#include <unistd.h>
#define HANDLE_SYSCALL_RETURN_VALUE(syscall_name, rc, success_value) \
@ -241,4 +242,19 @@ ErrorOr<void> ioctl(int fd, unsigned request, ...)
return {};
}
ErrorOr<struct termios> tcgetattr(int fd)
{
struct termios ios = {};
if (::tcgetattr(fd, &ios) < 0)
return Error::from_syscall("tcgetattr"sv, -errno);
return ios;
}
ErrorOr<void> tcsetattr(int fd, int optional_actions, struct termios const& ios)
{
if (::tcsetattr(fd, optional_actions, &ios) < 0)
return Error::from_syscall("tcsetattr"sv, -errno);
return {};
}
}