Fix fatal error on Mac OS X - redmine 6578

*BSD use unsigned long as second argument to ioctl() while POSIX
 specifies *signed* int.