0

このループを機能させるのに問題があります。

const char* filename = "test.txt";

int inotfd = inotify_init();

int watch_desc = inotify_add_watch(inotfd, filename, IN_MODIFY);


size_t bufsize = sizeof(struct inotify_event) + PATH_MAX + 1;

struct inotify_event* event = (inotify_event*)malloc(bufsize);

while (true) {

    read(inotfd, event, bufsize);

    //Does smth here
}

問題は、ループが 1 回しかないことです。最初のDoes smth here行の後、ループは終了します。

さらに、inotifyテキスト ファイルがアプリケーションの外部でいつ変更されたかを知るために使用しています。read()ファイルが変更されるのを待つだけなので、ループ内で必要です。

4

0 に答える 0