Removed some duplication with Boost.Config.
GetLastError and errno usage made more reliable. Fixes #8925.