#2572 basic FreeBSD support

This is stripped code from endyman with some changes to provide basic support for FreeBSD