fsevent notifications not consistent on linux. Luvit.

8 views
Skip to first unread message

Shreyansh Chouhan

unread,
Jun 8, 2020, 2:34:30 AM6/8/20
to libuv
I was using libuv through luvit to watch a file for fs notifications. And I used the C
code written at the end of this mail to edit the file. For some reason, not all the writes lead
to the execution of the callback.

Also another weird thing that I noticed was that if I edited the watched file using an editor, (say gedit or nano,) all
the notifications were registered and the callback was called after every save/write.

I used the following C code to write different lines to a file one by one, and found that
the callbacks were skipped for a few writes. (Also, if it helps, I tried using inotify to
monitor the same file, and it just worked. The execution of callbacks was not skipped
for a single write.)

C Code (two files one uses write and the other fwrite, both caused skips):
#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>

int main (int argc, char **argv) {
 
if(argc != 2) {
    printf
("You fool\n");
   
return 0;
 
}

 
int x = argv[1][0] - '0';

 
int fd;
 
char str[4][8] = {
   
{'l', 'i', 'n', 'e', ' ', '1', '\n', '\0'},
   
{'l', 'i', 'n', 'e', ' ', '2', '\n', '\0'},
   
{'l', 'i', 'n', 'e', ' ', '3', '\n', '\0'},
   
{'l', 'i', 'n', 'e', ' ', '4', '\n', '\0'}
 
};

  fd
= open("test", O_WRONLY | O_APPEND);
  write
(fd, str[x], sizeof(str[x]));

  close
(fd);

 
return 0;
}

#include<stdio.h>
#include<unistd.h>

int main (int argc, char **argv) {
 
if(argc != 2) {
    printf
("You fool\n");
   
return 0;
 
}

 
int x = argv[1][0] - '0';

  FILE
*fp;
 
char str[4][8] = {
   
{'l', 'i', 'n', 'e', ' ', '1', '\n', '\0'},
   
{'l', 'i', 'n', 'e', ' ', '2', '\n', '\0'},
   
{'l', 'i', 'n', 'e', ' ', '3', '\n', '\0'},
   
{'l', 'i', 'n', 'e', ' ', '4', '\n', '\0'}
 
};

  fp
= fopen("test", "a");
  fwrite
(str[x], 1, sizeof(str[x]), fp);

  fclose
(fp);

 
return 0;
}


Shreyansh Chouhan

unread,
Jun 8, 2020, 12:33:21 PM6/8/20
to libuv
Whoops, looks like it isn't related to libuv. I just tried it with libuv in c and it works flawlessly. Must be something on the side of luvit then?
Anyways sorry for the noise :)
Reply all
Reply to author
Forward
0 new messages