import time
import fcntl
import os
import signal

FNAME = "/tmp/test"

def handler(signum, frame):
    pass
#    print "File %s modified" % (FNAME,)

signal.signal(signal.SIGIO, handler)
fd = os.open(FNAME,  os.O_RDONLY)
fcntl.fcntl(fd, fcntl.F_SETSIG, 0)
fcntl.fcntl(fd, fcntl.F_NOTIFY,
            fcntl.DN_MODIFY | fcntl.DN_CREATE | fcntl.DN_MULTISHOT)

print "sleeping..."
time.sleep(20)
print "waking up now"
os.close(fd)