Skip to content

Instantly share code, notes, and snippets.

@tiebingzhang
tiebingzhang / filewatch.c
Created July 14, 2015 18:49
This is the sample program to notify us when the file /tmp/myinput is modified
/*This is the sample program to notify us when the file /tmp/myinput is modified */
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <linux/inotify.h>
#define EVENT_SIZE ( sizeof (struct inotify_event) )
#define EVENT_BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) )