From d288c700c7caedbb2963dddac94a80097fde0798 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Wed, 8 Jun 2022 14:39:59 +0200 Subject: [PATCH] LibCore: Add a wrapper for endgrent() --- Userland/Libraries/LibCore/System.cpp | 11 +++++++++++ Userland/Libraries/LibCore/System.h | 1 + 2 files changed, 12 insertions(+) diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index ce810cd925..13834394f4 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -687,6 +687,17 @@ ErrorOr lseek(int fd, off_t offset, int whence) return rc; } +ErrorOr endgrent() +{ + int old_errno = 0; + swap(old_errno, errno); + ::endgrent(); + if (errno != 0) + return Error::from_syscall("endgrent", -errno); + errno = old_errno; + return {}; +} + ErrorOr waitpid(pid_t waitee, int options) { int wstatus; diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index 75364d8b1d..1d73d28380 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -100,6 +100,7 @@ ErrorOr clock_settime(clockid_t clock_id, struct timespec* ts); ErrorOr posix_spawn(StringView path, posix_spawn_file_actions_t const* file_actions, posix_spawnattr_t const* attr, char* const arguments[], char* const envp[]); ErrorOr posix_spawnp(StringView path, posix_spawn_file_actions_t* const file_actions, posix_spawnattr_t* const attr, char* const arguments[], char* const envp[]); ErrorOr lseek(int fd, off_t, int whence); +ErrorOr endgrent(); struct WaitPidResult { pid_t pid;