From 71728f3ea6da0ea656b9d73889e04def17f51aa3 Mon Sep 17 00:00:00 2001 From: Peter Elliott Date: Mon, 5 Sep 2022 22:12:58 -0600 Subject: [PATCH] LibCore: Add Core::System wrapper for getsid() --- Userland/Libraries/LibCore/System.cpp | 8 ++++++++ Userland/Libraries/LibCore/System.h | 1 + 2 files changed, 9 insertions(+) diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index 32884186d9..b89e34c48b 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -747,6 +747,14 @@ ErrorOr setsid() return rc; } +ErrorOr getsid(pid_t pid) +{ + int rc = ::getsid(pid); + if (rc < 0) + return Error::from_syscall("getsid"sv, -errno); + return rc; +} + ErrorOr drop_privileges() { auto gid_result = setgid(getgid()); diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index aa578ac62b..fd9a4d7603 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -141,6 +141,7 @@ ErrorOr setgid(gid_t); ErrorOr setegid(gid_t); ErrorOr setpgid(pid_t pid, pid_t pgid); ErrorOr setsid(); +ErrorOr getsid(pid_t pid = 0); ErrorOr drop_privileges(); ErrorOr isatty(int fd); ErrorOr link(StringView old_path, StringView new_path);