Improve handling of mlock error codes.