diff options
author | Lucas CHOLLET <lucas.chollet@free.fr> | 2022-12-11 23:40:25 +0100 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2022-12-12 16:14:11 +0000 |
commit | 5532640b7178195060422934b8e10b128ab9a8de (patch) | |
tree | dcd33470b4f3f3ccddcde8d1e9dcdbc0039f66c8 | |
parent | 0049dfd71716a5c2bb1ed54c312674e1f6b1568c (diff) | |
download | serenity-5532640b7178195060422934b8e10b128ab9a8de.zip |
LibCore: Add a wrapper for `poll()`
-rw-r--r-- | Userland/Libraries/LibCore/System.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibCore/System.h | 2 |
2 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index c2bb6f135a..46b92231dd 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -1410,6 +1410,14 @@ ErrorOr<DeprecatedString> readlink(StringView pathname) #endif } +ErrorOr<int> poll(Span<struct pollfd> poll_fds, int timeout) +{ + auto const rc = ::poll(poll_fds.data(), poll_fds.size(), timeout); + if (rc < 0) + return Error::from_syscall("poll"sv, -errno); + return { rc }; +} + #ifdef AK_OS_SERENITY ErrorOr<void> posix_fallocate(int fd, off_t offset, off_t length) { diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index 78e22d3067..986d2d57c8 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -13,6 +13,7 @@ #include <dirent.h> #include <fcntl.h> #include <grp.h> +#include <poll.h> #include <pwd.h> #include <signal.h> #include <spawn.h> @@ -205,6 +206,7 @@ ErrorOr<void> grantpt(int fildes); ErrorOr<void> unlockpt(int fildes); ErrorOr<void> access(StringView pathname, int mode); ErrorOr<DeprecatedString> readlink(StringView pathname); +ErrorOr<int> poll(Span<struct pollfd>, int timeout); #ifdef AK_OS_SERENITY ErrorOr<void> posix_fallocate(int fd, off_t offset, off_t length); |