id summary reporter owner description type status milestone component version severity resolution keywords cc 9597 """boost::iostreams::file_descriptor"" doesn't close Windows low-level file descriptors properly when specifying ""file_descriptor_flags::close_handle""" anonymous Jonathan Turkanis "When opening a file on Windows using {{{boost::iostreams::file_descriptor}}}, {{{boost::iostreams::file_descriptor_sink}}} or {{{boost::iostreams::file_descriptor_source}}} in combination with a low-level file descriptor and when specifying {{{file_descriptor_flags::close_handle}}}, then the file descriptor isn't closed properly on close/exit. Using one of the mentioned methods, the low-level file descriptor is converted to a Windows handle using the API call {{{_get_osfhandle}}} [#point1 (1)]: {{{#!c++ void file_descriptor_impl::open(int fd, flags f) { open(reinterpret_cast(_get_osfhandle(fd)), f); } }}} When closing, the file handle is closed using {{{CloseHandle}}}: {{{#!c++ void file_descriptor_impl::close_impl(bool close_flag, bool throw_) { if (handle_ != invalid_handle()) { if (close_flag) { bool success = #ifdef BOOST_IOSTREAMS_WINDOWS ::CloseHandle(handle_) == 1; #else BOOST_IOSTREAMS_FD_CLOSE(handle_) != -1; #endif if (!success && throw_) throw_system_failure(""failed closing file""); } handle_ = invalid_handle(); flags_ = 0; } } }}} According to [#point1 (1)] the API call {{{_close}}} [#point2 (2)] shall be used to close a low-level file descriptor. Practical tests shew that every time a file is opened and closed using one of the mentioned methods, Windows (XP) assigns a new file descriptor with an increasing value to it, unless the program runs out of available file handles. Manually closing the file by specifying {{{file_descriptor_flags::close_handle}}} and calling {{{_close}}} solves this issue. [=#point1 (1)] http://msdn.microsoft.com/en-us/library/ks2530z6.aspx \\ [=#point2 (2)] http://msdn.microsoft.com/en-us/library/5fzwd5ss.aspx" Bugs new To Be Determined iostreams Boost 1.55.0 Problem file_descriptor m.kosch@…