diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-28 12:08:28 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-28 23:14:19 +0100 |
commit | 83056efc1af1a9e8bffcb14404d12498e54fc17b (patch) | |
tree | 6bef5d9082576032e7bf5f86391d3200de93d999 /Userland | |
parent | cb9cac4e4002d6f2d5a16c7344dfb5393cec2b56 (diff) | |
download | serenity-83056efc1af1a9e8bffcb14404d12498e54fc17b.zip |
LibCore: Add syscall wrapper for dup()
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibCore/System.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibCore/System.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index 8e241749cc..b0198294fe 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -196,6 +196,14 @@ ErrorOr<void> kill(pid_t pid, int signal) return {}; } +ErrorOr<int> dup(int source_fd) +{ + int fd = ::dup(source_fd); + if (fd < 0) + return Error::from_syscall("dup"sv, -errno); + return fd; +} + ErrorOr<int> dup2(int source_fd, int destination_fd) { int fd = ::dup2(source_fd, destination_fd); diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index 2f4d61ea42..121867701c 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -32,6 +32,7 @@ ErrorOr<struct stat> stat(StringView path); ErrorOr<ssize_t> read(int fd, Bytes buffer); ErrorOr<ssize_t> write(int fd, ReadonlyBytes buffer); ErrorOr<void> kill(pid_t, int signal); +ErrorOr<int> dup(int source_fd); ErrorOr<int> dup2(int source_fd, int destination_fd); ErrorOr<String> ptsname(int fd); ErrorOr<String> gethostname(); |