diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-09-14 15:49:39 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-11-19 17:00:10 +0000 |
commit | 376b5731a212cb2082169638192db5166f93f8c6 (patch) | |
tree | 470b4e9291e57bce73c45499a6974cdc769cecbc /Userland | |
parent | 9e4689f4c82391b7b1e3767a3e2b95137e87628f (diff) | |
download | serenity-376b5731a212cb2082169638192db5166f93f8c6.zip |
lsof: Port to Core::Stream
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Utilities/lsof.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Userland/Utilities/lsof.cpp b/Userland/Utilities/lsof.cpp index 9c280ec33f..46e9aaad97 100644 --- a/Userland/Utilities/lsof.cpp +++ b/Userland/Utilities/lsof.cpp @@ -11,8 +11,8 @@ #include <AK/String.h> #include <AK/Vector.h> #include <LibCore/ArgsParser.h> -#include <LibCore/File.h> #include <LibCore/ProcessStatisticsReader.h> +#include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> #include <ctype.h> @@ -65,14 +65,18 @@ static bool parse_name(StringView name, OpenFile& file) static Vector<OpenFile> get_open_files_by_pid(pid_t pid) { - auto file = Core::File::open(String::formatted("/proc/{}/fds", pid), Core::OpenMode::ReadOnly); + auto file = Core::Stream::File::open(String::formatted("/proc/{}/fds", pid), Core::Stream::OpenMode::Read); if (file.is_error()) { outln("lsof: PID {}: {}", pid, file.error()); return Vector<OpenFile>(); } auto data = file.value()->read_all(); + if (data.is_error()) { + outln("lsof: PID {}: {}", pid, data.error()); + return {}; + } - auto json_or_error = JsonValue::from_string(data); + auto json_or_error = JsonValue::from_string(data.value()); if (json_or_error.is_error()) { outln("lsof: {}", json_or_error.error()); return Vector<OpenFile>(); |