added conditional logic (can be improved for other versions of bsd/solaris/*nix)
Merge pull request #1 from moradology/feature/non-gnu

osx support