diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index c1a66dac17..ccaa2ed5cb 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #define HANDLE_SYSCALL_RETURN_VALUE(syscall_name, rc, success_value) \ if ((rc) < 0) { \ @@ -115,4 +116,11 @@ ErrorOr open(StringView path, int options, ...) #endif } +ErrorOr close(int fd) +{ + if (::close(fd) < 0) + return Error::from_syscall("close"sv, -errno); + return {}; +} + } diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index 07179cf78f..de2259683f 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -23,5 +23,6 @@ ErrorOr fcntl(int fd, int command, ...); ErrorOr mmap(void* address, size_t, int protection, int flags, int fd, off_t, size_t alignment = 0, StringView name = {}); ErrorOr munmap(void* address, size_t); ErrorOr open(StringView path, int options, ...); +ErrorOr close(int fd); }