From 1b5dd78a4ff7c866b7a21d72bd9245505fe1d826 Mon Sep 17 00:00:00 2001 From: fadhil riyanto Date: Sun, 18 Aug 2024 10:27:18 +0700 Subject: test file Signed-off-by: fadhil riyanto --- inotify.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 inotify.c (limited to 'inotify.c') diff --git a/inotify.c b/inotify.c new file mode 100644 index 0000000..6059d20 --- /dev/null +++ b/inotify.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include +#include + +typedef int FD ; + +int main() { + FD filed = open("/tmp/test_inotify", O_RDWR ); + char buf[128]; + + if( !filed ) { + printf("Openfile error\n"); + exit(-1); + } + + int nbytes; + while(1) { + nbytes = read(filed, buf, 16); + printf("read %d bytes from file.\n", nbytes); + if(nbytes > 0) { + printf("%s\n", buf); // split buffer by new line. + } + sleep(1); + } + return 0; +} -- cgit v1.2.3