inotify를 사용할 때 몇 가지 문제가 발생합니다. inotify를 사용하여 파일의 변경 사항을 모니터링합니다. 나는 "/ 루트/온도"를 삭제하고 같은 파일을 다시 작성하는 경우,이 파일에 대한 변경 사항은 inotify를 모니터링하지 않는inotify는 파일을 삭제하고 다시 만들 때 파일 모니터링을 중지합니다.
int fd = inotify_init();
int wd = inotify_add_watch(fd, "/root/temp", IN_ALL_EVENTS);
int bufSize = 1000;
char *buf = new char[bufSize];
memset(buf, 0, sizeof(buf));
int nBytes = read(fd, buf, bufSize - 1);
cout << nBytes << " bytes read" << endl;
inotify_event *eventPtr = (inotify_event *)buf;
int offset = 0;
while (offset < nBytes)
{
cout << eventPtr->mask << endl;
offset += sizeof(inotify_event) + eventPtr->len;
eventPtr = (inotify_event *)(buf + offset);
}
delete []buf;
이 얼마나 사람 : 여기 내 코드는? 감사. 당신이 API를 사용할 때마다
쳉