From 59c886d85500cf4c8ae11eaf2ebe50ec25b596f6 Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 5 Jun 2025 22:19:54 +0800 Subject: [PATCH] internal: Catch filesystem exceptions while iterating RunTimeDir (#10648) --- hyprctl/main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp index 25a4eef3..4a8b9819 100644 --- a/hyprctl/main.cpp +++ b/hyprctl/main.cpp @@ -72,10 +72,13 @@ std::vector instances() { return {}; } catch (std::exception& e) { return {}; } - for (const auto& el : std::filesystem::directory_iterator(getRuntimeDir())) { + std::error_code ec; + std::filesystem::directory_iterator it = std::filesystem::directory_iterator(getRuntimeDir(), std::filesystem::directory_options::skip_permission_denied, ec); + if (ec) + return {}; + for (const auto& el : it) { if (!el.is_directory() || !std::filesystem::exists(el.path().string() + "/hyprland.lock")) continue; - // read lock SInstanceData* data = &result.emplace_back(); data->id = el.path().filename().string();