26volatile std::sig_atomic_t G_PARENT_OK = 0;
54 signal(SIGPIPE, SIG_IGN);
56 return_if(argc < 3, Error(
"E::Incorrect usage: fim_janitor <parent_pid> <log_path>"));
58 pid_t pid_parent = Try(std::stoi(argv[1]));
60 std::string path_log_file = argv[2];
62 pid_t pid_session = setsid();
63 return_if(pid_session < 0, Error(
"E::Failed to create a novel session for janitor"));
69 logger(
"I::Session id is '{}'", pid_session);
71 while (not G_PARENT_OK and kill(pid_parent, 0) == 0)
73 std::this_thread::sleep_for(std::chrono::milliseconds{100});
78 logger(
"I::Parent process with pid '{}' finished", pid_parent);
82 logger(
"E::Parent process with pid '{}' failed to send skip signal", pid_parent);
84 for (
auto&& path_dir_mountpoint : std::vector<std::filesystem::path>(argv+2, argv+argc))
86 logger(
"I::Un-mount '{}'", path_dir_mountpoint);
87 ns_fuse::unmount(path_dir_mountpoint).discard(
"E::Could not un-mount '{}'", path_dir_mountpoint);
99int main(
int argc,
char** argv)
102 Pop(
boot(argc, argv),
"C::Failure to start janitor");
Enhanced error handling framework built on std::expected.
constexpr auto __expected_fn
Lambda helper for Pop macro error returns.
A library for operations on fuse filesystems.
Value< void > boot(int argc, char **argv)
Boots the main janitor program.
void cleanup(int sig)
Signal handler for parent process exit detection.
A library for file logging.
#define logger(fmt,...)
Compile-time log level dispatch macro with automatic location capture.
Simplified macros for common control flow patterns with optional logging.
Value< int > unmount(fs::path const &path_dir_mount)
Un-mounts the given fuse mount point.
void set_as_fork()
Marks the logger as being in a forked child process.
void set_level(Level level)
Sets the logging verbosity (CRITICAL,ERROR,INFO,DEBUG)
void set_sink_file(fs::path const &path_file_sink)
Sets the sink file of the logger.
int main()
Entry point for the portal daemon.
Enhanced expected type with integrated logging capabilities.