Skip to content

Commit

Permalink
fastgame_apply: monitoring the removal of the presets file and exitti…
Browse files Browse the repository at this point in the history
…ng accordingly
  • Loading branch information
wwmm committed Sep 17, 2024
1 parent 0fd0a46 commit 8a4a4fe
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/fastgame_apply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ptree_fwd.hpp>
#include <chrono>
#include <cstdint>
#include <filesystem>
#include <fstream>
Expand Down Expand Up @@ -342,7 +343,21 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int {

// nl->new_exit.connect([&](int pid) {});

auto check_lock_file = [&]() {
while (std::filesystem::is_regular_file(input_file)) {
std::this_thread::sleep_for(std::chrono::seconds(1));
}

util::info("The lock file has been removed. Exitting the lock thread.");

nl->listen = false;
};

if (nl->listen) {
std::thread t(check_lock_file);

t.detach();

nl->handle_events(); // This is a blocking call. It has to be started at the end

util::info("Netlink event monitor finished.");
Expand Down

0 comments on commit 8a4a4fe

Please sign in to comment.