The implementation is taken from FreeBSD with #ifdef __CYGWIN__ modifications. Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>