1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-11-25 14:06:08 -05:00

file_watch: don't watch special files

While /dev/null is always empty, it still generates inotify events. So
using /dev/null as config file will cause the compositor to reset itself
frequently.

Not entire sure if only allowing regular files is sufficient, but we
will be doing this until an issue comes up.

Fixes #320

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2020-02-26 21:11:55 +00:00
parent 630d6f3a26
commit a8e8b747fe
No known key found for this signature in database
GPG key ID: 37C999F617EA1A47

View file

@ -126,6 +126,18 @@ bool file_watch_add(void *_fwr, const char *filename, file_watch_cb_t cb, void *
log_debug("Adding \"%s\" to watched files", filename); log_debug("Adding \"%s\" to watched files", filename);
auto fwr = (struct file_watch_registry *)_fwr; auto fwr = (struct file_watch_registry *)_fwr;
int wd = -1; int wd = -1;
struct stat statbuf;
int ret = stat(filename, &statbuf);
if (ret < 0) {
log_error_errno("Failed to retrieve information about file \"%s\"", filename);
return false;
}
if (!S_ISREG(statbuf.st_mode)) {
log_info("\"%s\" is not a regular file, not watching it.", filename);
return false;
}
#ifdef HAS_INOTIFY #ifdef HAS_INOTIFY
wd = inotify_add_watch(fwr->w.fd, filename, wd = inotify_add_watch(fwr->w.fd, filename,
IN_CLOSE_WRITE | IN_MOVE_SELF | IN_DELETE_SELF); IN_CLOSE_WRITE | IN_MOVE_SELF | IN_DELETE_SELF);