fswatch icon indicating copy to clipboard operation
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?

Open 9527567 opened this issue 3 years ago • 0 comments

#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();
}

9527567 avatar Apr 03 '23 08:04 9527567