Forcing an open file closed in (ANSI) C

116 views Asked by At

I have a SCADA system (Siemens WinCC Classic 7.5) where there is data exchange between a storage facility and my system, based on text files.

Sometimes (very rarely, maybe 1 in 2000) it crashes the connection to the network drives where the files are exchanged. The only way to fully recover is to restart the server (Windows 2019).

I suspect that what happens is, that one file is reopened by the SCADA program, before it is actually closed again, because the file is processed cyclically every 1 seconds.

Closing of the file is implemented (with error handling as well) and works during normal operation. However, if the file is opened and not closed by the same function, I lack a way to "forcefully" close it.

Does anyone know of the golden solution to finding and closing/terminating open files without restarting the entire server?

I use fopen() to open the file, and it's normally closed with fclose(). This works fine normally. But if the file is opened with fopen() and not closed in the same function, the file remains open and cannot be renamed/deleted without restarting.

I hope the above makes sense, because it's a pretty complex system so it's difficult to summarize in such short terms. I've searched far and wide and not been able to find a suitable solution. This is made even more difficult by being locked by only having the Siemens-enabled C-functions.

0

There are 0 answers