I have a little problem that I wish you could help.
I have a data acquisition system implemented in Neutrino 6.3.0 SP2. The system can be turned off instantly without notice.
The problem is: when the system is again turned on the files that were opened before the power off stays in a ‘busy state’ and is impossible to access them via an open() call. Only after a chkfsys is possible again to gain access to these files.
Is this something I’m doing wrong? Maybe something about flags in open() call.
In fact I forgot to mention that we have some time before the system turns off. We have time to kill the process that opened files (aprox. 200 ms) and that is what we do through a watchdog process that inspects if the power source is going to a state of power loss. The point is: apparently, only killing the processes didn’t seem to close properly the files inside the filesystem.
Is there an open mode that flushes files to filesystem leaving it in a “non-corrupted state”? I mean, in my case, a mode that leaves me with “not busy” files after a sudden system power down.
When you say you have 200 ms to kill the process, does this mean your dropping a signal on it to kill it?
If so, you could install a signal handler and close the files there to make sure they are closed (instead of left open when you kill the process). It’s technically not safe to close the files from there but since your about to die anyway, I’m not sure there’s much to lose.