Revert "Try using POSIX fcntl instead of ioctl. Let's see what mingw thinks of this."

This reverts commit d7c0960989280c68f5b569e69bd0a8ae6987c9df.
Well that didn't work.