Question

I am using JNotify in one of my Projects on a linux system (arm7). And it works great. If i change, rename, delete or create a File it throws an Interrupt. But I would like to us JNotify to get informed if the Linux System change a File by itself. I am using a BeagleBone (embeded Linux System). There is a file called value which contains the status of an InputPin (high, low). But if this file is changed by the system JNotify dosen't work... If I change the file by my self everything is ok... Does anyone know why the change wasn't recognize in the first case. Linux seems to use a special way to write the file... yet i dont't know how... But need to interrupt my main loop if this file changes. Or is there another solution?

Thanks

Was it helpful?

Solution

JNotify relies on events from the file system. for Linux it's using the inotify system call (which is actually what inspired it's name). inotify only works for real file, the file you are described is a virtual file that does not exist on disk and is not a way to store information but rather an easy way to access system information and sometimes change it).

an alternative solution would be to create a sampling thread that will check the file, sleep, and check the file again. since you only care about a specific file, this is pretty easy.

while it may feel too expensive, polling is actually very common when dealing directly with hardware. since that file is actually not really a file, reading it would actually be faster than reading a file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top