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 kill(pid_t pid, int signal) return {}; } +ErrorOr dup(int source_fd) +{ + int fd = ::dup(source_fd); + if (fd < 0) + return Error::from_syscall("dup"sv, -errno); + return fd; +} + ErrorOr 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 stat(StringView path); ErrorOr read(int fd, Bytes buffer); ErrorOr write(int fd, ReadonlyBytes buffer); ErrorOr kill(pid_t, int signal); +ErrorOr dup(int source_fd); ErrorOr dup2(int source_fd, int destination_fd); ErrorOr ptsname(int fd); ErrorOr gethostname();