inotify file in C

前端 未结 4 1426
悲哀的现实
悲哀的现实 2020-12-20 15:38

I am trying to run an example of inotify in C..but it\'s not working. I want to monitor modifications to a file (the file is tmp.cfg), but it doesn\'t work..I don\'t know if

4条回答
  •  清酒与你
    2020-12-20 16:09

    I think you're not using your user name, which is your home directory, and you're not checking the return of inotify_add_watch which probably fails:

    "/home/name/tmp.cfg"
    

    Edit: okay second problem, you shouldn't print name because

    The name field is only present when an event is returned for a file inside a watched directory;

    Edit2: third problem, the file must exist before you run the program because you add a watch on the file, I suggest you check the error from inotify_add_watch

提交回复
热议问题