Use a more portable method of reading OS version.
(cherry picked from commit b067bf56c86e6453c22196ea7f515c7cb896fb58)