You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into a problem with the removal of temporary files created during a run of an import script I wrote for a customer, which seems to primarily affect Windows due to a difference in file locking behavior.
At https://github.com/rapid7/nexpose-client/blob/master/lib/nexpose/scan.rb#L410, the file is opened using File.new, but is not closed, leaving behind an open handle with no primary references outside of the global ObjectSpace instance.
Windows interprets the open handle as locked and in use, preventing removal of the file referenced.
I worked around this by iterating through open IO handles in ObjectSpace and closing them, but the behavior is a bit confusing and took me some time to track down.
The fix should trivial, just a matter of adding "scan.close" before the function returns to close the handle.
The text was updated successfully, but these errors were encountered:
I think I'll just change this code to use a block so the file is closed automatically without having to worry about rescuing on any errors. The export method is done that way already.
I ran into a problem with the removal of temporary files created during a run of an import script I wrote for a customer, which seems to primarily affect Windows due to a difference in file locking behavior.
At https://github.com/rapid7/nexpose-client/blob/master/lib/nexpose/scan.rb#L410, the file is opened using File.new, but is not closed, leaving behind an open handle with no primary references outside of the global ObjectSpace instance.
Windows interprets the open handle as locked and in use, preventing removal of the file referenced.
I worked around this by iterating through open IO handles in ObjectSpace and closing them, but the behavior is a bit confusing and took me some time to track down.
The fix should trivial, just a matter of adding "scan.close" before the function returns to close the handle.
The text was updated successfully, but these errors were encountered: