Fix output streams on Windows for GUI executables.

Direct *STDIN*, *STDOUT*, and *STDERR* to NUL on Windows when the
standard handles are not available.

Patch by Wilfredo Velazquez. Fixes lp#125603.
Linux/MIPS uses "unsigned long" instead of dev_t in struct stat

Handle rdev the same way as dev.