Implement init/deinit of inotify system

Use RAII to handle inotify resource lifetime, i.e. initialize with actor
creation and deinitialize with actor deletion.
This commit is contained in:
T. R. Bernstein
2026-03-11 17:25:27 +01:00
parent 1a7e5ca5de
commit 098339f9d1
6 changed files with 65 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
#ifndef CINOTIFY_H
#define CINOTIFY_H
#include <stdlib.h>
#include <sys/inotify.h>
#include <errno.h>
static inline int cinotify_deinit(int fd) {
return close(fd);
}
static inline int cinotify_get_errno(void) {
return errno;
}
static inline char* get_error_message() {
int error_number = errno;
errno = 0;
char* error_message = strerror(error_number);
if (errno > 0) return NULL;
return error_message;
}
#endif