Proper cleanup for deployed process signaler #259
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On Windows calling GetTempFileName results in a 0 size unique file created to ensure the availability of the temp file name. These are not automatically deleted as per documentation (the OS probably will do some cleanup from time to time thou).
https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettempfilenamew
Using .NET 7 and below there is limit of 65535 unique temp files names as GetTempFileNameW is used (this limitation is removed in .NET 8+) If we look and the .NET 8 implementation (which I'm guessing follows the WIN32 implementation somewhat), a loop is use to find a unique temp filename, which at least as observed for .NET 6 on Windows, will result in very high CPU utilization when nearing the unique temp file name limit as the numbers of name collision becomes very high.
https://github.com/dotnet/runtime/blob/v8.0.8/src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs
To avoid problems with temp file leaking we simply generate our own temp filename using
GetTempPath()
and a UUID.Closes #258