Last active
June 13, 2017 16:04
Revisions
-
talshorer revised this gist
Jun 13, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) read(ifd, &event.ie, sizeof(event.buf)); fd = open(argv[1], O_RDONLY); if (fd < 0) return i; n = read(fd, state, sizeof(state)); state[n - 1] = 0; close(fd); -
talshorer created this gist
Jun 13, 2017 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ #include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <stdbool.h> #include <sys/inotify.h> int main(int argc, char *argv[]) { int ifd; union { struct inotify_event ie; unsigned char buf[0x200]; } event; unsigned int i = 1; int fd; int n; char state[0x100]; if (argc < 2) return i; i++; ifd = inotify_init(); if (ifd < 0) return i; i++; if (inotify_add_watch(ifd, argv[1], IN_MODIFY) < 0) return i; i++; while (true) { read(ifd, &event.ie, sizeof(event.buf)); fd = open(argv[1], O_RDONLY); if (fd < 0) continue; n = read(fd, state, sizeof(state)); state[n - 1] = 0; close(fd); if (!strcmp(state, "configured")) return 0; } }