windows: fix compatibility with cygwin pipes

This makes libuv more tolerant of the properties of the pipes
that it can use. this is necessary because Cygwin (and hence Mintty)
opens `STDIN` without `FILE_WRITE_ATTRIBUTES`. Also, this always duplicate
handles from external sources, to ensure the original handle can remain
valid after uv_close (this can be important for stdio since the system
libraries do not expect it to be closed by the user).
Unneeded cast?