diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index ab7be608f4..358eed6c2d 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -179,4 +179,12 @@ ErrorOr kill(pid_t pid, int signal) return {}; } +ErrorOr dup2(int source_fd, int destination_fd) +{ + int fd = ::dup2(source_fd, destination_fd); + if (fd < 0) + return Error::from_syscall("dup2"sv, -errno); + return fd; +} + } diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index 70300ceffa..86cf78d60e 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -30,5 +30,6 @@ ErrorOr stat(StringView path); ErrorOr read(int fd, void* buffer, size_t buffer_size); ErrorOr write(int fd, void const* data, size_t data_size); ErrorOr kill(pid_t, int signal); +ErrorOr dup2(int source_fd, int destination_fd); }