modelica-tools / FMUComplianceChecker

FMI Compliance Checker for validation of FMUs 1.0 and 2.0
BSD 3-Clause "New" or "Revised" License
42 stars 31 forks source link

The output file -o protocol.csv is not opened with Close-On-Exec semantics #63

Open konrad-schwarz opened 2 years ago

konrad-schwarz commented 2 years ago

In our non-trivial co-simulation setup, a separate (operating system) process is started to perform the simulation. For various reasons, this process is not terminated immediately after the simulation run.

'csv-compare/Compare' from the modelica-tools then fails to open the output file produced by FmuChecker, because the sub-ordinate process still has an (inherited) open file descriptor to the output file and the file has been opened using the usual Microsoft file locking semantics.

This problem can be solved by marking the file descriptor close-on-exec. In the Win32 API, this is achieved by calling SetHandleInformation on the file descriptor (handle) with the HANDLE_FLAG_INHERIT set in the dwMask parameter and clear in the dwFlags parameter.

See SetHandleInformation. Alternatively, the output file could be opened with more liberal SHARE_DENY settings.