이벤트 감시(watchdog)

Jongwon·2021년 12월 10일
0

Linux Programming

목록 보기
17/25

파일에 대해 이벤트가 발생하면 알려주는 기능, 운영체제 자체가 inotify 기능을 가져야만 실현이 가능하다.

struct inotify {
    int wd;
    unit32_t mask;
    unit32_t cookie;
    unit32_t len;
    char name[];
}

<sys/inotify.h> 헤더

  • int inotify_init(void) inotify 객체 생성 후, 해당 fd 반환
    inotify fd는 read하면 이벤트 올 때까지 잠들어있음.
  • int inotify_add_watch(int fd, const char *path, uint32_t mask)
    watch할 path, watch할 이벤트들(mask)를 추가
  • int inotify_rm_watch(int fd, int wd)
  • int close(int fd)
profile
Backend Engineer

0개의 댓글