diff --git a/Userland/Libraries/LibCore/File.cpp b/Userland/Libraries/LibCore/File.cpp index a8e62d05a0..0f30a995cb 100644 --- a/Userland/Libraries/LibCore/File.cpp +++ b/Userland/Libraries/LibCore/File.cpp @@ -92,6 +92,12 @@ bool File::open_impl(OpenMode mode, mode_t permissions) return true; } +int File::leak_fd() +{ + m_should_close_file_descriptor = ShouldCloseFileDescriptor::No; + return fd(); +} + bool File::is_device() const { struct stat stat; diff --git a/Userland/Libraries/LibCore/File.h b/Userland/Libraries/LibCore/File.h index 5ce8161ae8..cb81920d1d 100644 --- a/Userland/Libraries/LibCore/File.h +++ b/Userland/Libraries/LibCore/File.h @@ -74,6 +74,7 @@ public: Yes }; bool open(int fd, OpenMode, ShouldCloseFileDescriptor); + [[nodiscard]] int leak_fd(); static NonnullRefPtr standard_input(); static NonnullRefPtr standard_output();