inotify: recover from interrupted system call

When the thread is paused, e.g. when entering sleep mode, os.read will be interrupted first. Currently the script is not able to recover from that.