Fix compatibility issues with Illumos.

Thanks to Theo Schlossnagle.