fswatch
fswatch copied to clipboard
When I run fswatch on an additional thread that starts, it cannot be closed by CTRL C. Why is this happening?
#include <fswatch.hpp>
#include <iostream>
#include <thread>
void go()
{
auto watcher = fswatch("~", "/opt", ".");
watcher.on(fswatch::Event::FILE_CREATED, [](auto &event) {
std::cout << "File created: " << event.path << std::endl;
});
watcher.on(fswatch::Event::FILE_MODIFIED, [](auto &event) {
std::cout << "File modified: " << event.path << std::endl;
});
watcher.on(fswatch::Event::FILE_DELETED, [](auto &event) {
std::cout << "File deleted: " << event.path << std::endl;
});
try {
watcher.start();
} catch (std::filesystem::filesystem_error &error) {
std::cout << error.what() << std::endl;
}
}
int main() {
std::thread t1(go);
t1.join();
}