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;
}
--
You received this message because you are subscribed to the Google Groups
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/libuv/3119602f-b55b-42f8-bb22-917353532ed4o%40googlegroups.com.