Fix compatibility issues with Illumos.

Thanks to Theo Schlossnagle.
Merge branch 'master' into v2.1