summaryrefslogtreecommitdiff
path: root/Userland/Utilities/lsof.cpp
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-09-14 15:49:39 +0100
committerLinus Groh <mail@linusgroh.de>2022-11-19 17:00:10 +0000
commit376b5731a212cb2082169638192db5166f93f8c6 (patch)
tree470b4e9291e57bce73c45499a6974cdc769cecbc /Userland/Utilities/lsof.cpp
parent9e4689f4c82391b7b1e3767a3e2b95137e87628f (diff)
downloadserenity-376b5731a212cb2082169638192db5166f93f8c6.zip
lsof: Port to Core::Stream
Diffstat (limited to 'Userland/Utilities/lsof.cpp')
-rw-r--r--Userland/Utilities/lsof.cpp10
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>();