Avoid to pass a socket to setmode/isatty in Windows
Avoid to pass a socket to setmode/isatty in Windows

Summary:
In Windows, a socket is not a file descriptor. So passing it to
setmode/isatty causes an error that returns EABF and triggers invalid
parameter handler.

Test Plan:
1. Add WinDbg as a postmortem debugger (C:\>windbg -I)
2. Pass a socket to GHC.IO.Device.IODevice.isTerminal / GHC.IO.FD.fdToHandle'  (Executing 'cabal update' calls each functions with the socket in cabal-install 1.20.0.1)
3. WinDbg pops up and outputs error message: "Invalid parameter passed to C runtime function."
4. Apply the patch
5. Redo step 2
6. WinDbg doesn't pop up

Reviewers: austin

Reviewed By: austin

Subscribers: phaskell, simonmar, relrod, carter

Differential Revision: https://phabricator.haskell.org/D92

AlexanderPankiv/ghc,urbanslug/ghc,elieux/ghc,mcschroeder/ghc,gridaphobe/ghc,ghc-android/ghc,wxwxwwxxx/ghc,ezyang/ghc,christiaanb/ghc,urbanslug/ghc,vikraman/ghc,ezyang/ghc,christiaanb/ghc,elieux/ghc,ezyang/ghc,mfine/ghc,ghc-android/ghc,urbanslug/ghc,ml9951/ghc,nushio3/ghc,urbanslug/ghc,GaloisInc/halvm-ghc,da-x/ghc,sdiehl/ghc,wxwxwwxxx/ghc,christiaanb/ghc,acowley/ghc,holzensp/ghc,sgillespie/ghc,nushio3/ghc,acowley/ghc,sgillespie/ghc,urbanslug/ghc,gcampax/ghc,ml9951/ghc,fmthoma/ghc,spacekitteh/smcghc,siddhanathan/ghc,mfine/ghc,christiaanb/ghc,mettekou/ghc,elieux/ghc,lukexi/ghc,mettekou/ghc,TomMD/ghc,acowley/ghc,forked-upstream-packages-for-ghcjs/ghc,spacekitteh/smcghc,fmthoma/ghc,holzensp/ghc,nathyong/microghc-ghc,nkaretnikov/ghc,TomMD/ghc,da-x/ghc,mettekou/ghc,siddhanathan/ghc,forked-upstream-packages-for-ghcjs/ghc,mcschroeder/ghc,vikraman/ghc,acowley/ghc,forked-upstream-packages-for-ghcjs/ghc,ezyang/ghc,vikraman/ghc,nushio3/ghc,ghc-android/ghc,elieux/ghc,nkaretnikov/ghc,nathyong/microghc-ghc,fmthoma/ghc,GaloisInc/halvm-ghc,TomMD/ghc,christiaanb/ghc,vTurbine/ghc,nathyong/microghc-ghc,siddhanathan/ghc,oldmanmike/ghc,GaloisInc/halvm-ghc,ezyang/ghc,olsner/ghc,nathyong/microghc-ghc,shlevy/ghc,wxwxwwxxx/ghc,oldmanmike/ghc,snoyberg/ghc,nushio3/ghc,gcampax/ghc,gridaphobe/ghc,gcampax/ghc,da-x/ghc,forked-upstream-packages-for-ghcjs/ghc,vTurbine/ghc,jstolarek/ghc,vikraman/ghc,wxwxwwxxx/ghc,tjakway/ghcjvm,vTurbine/ghc,acowley/ghc,acowley/ghc,anton-dessiatov/ghc,sgillespie/ghc,olsner/ghc,vTurbine/ghc,AlexanderPankiv/ghc,AlexanderPankiv/ghc,ml9951/ghc,elieux/ghc,da-x/ghc,sgillespie/ghc,elieux/ghc,gridaphobe/ghc,shlevy/ghc,lukexi/ghc,nushio3/ghc,mfine/ghc,nkaretnikov/ghc,shlevy/ghc,sdiehl/ghc,bitemyapp/ghc,shlevy/ghc,snoyberg/ghc,green-haskell/ghc,snoyberg/ghc,GaloisInc/halvm-ghc,jstolarek/ghc,mfine/ghc,tjakway/ghcjvm,gridaphobe/ghc,anton-dessiatov/ghc,olsner/ghc,nkaretnikov/ghc,snoyberg/ghc,mcschroeder/ghc,ghc-android/ghc,vTurbine/ghc,snoyberg/ghc,gcampax/ghc,oldmanmike/ghc,oldmanmike/ghc,tjakway/ghcjvm,fmthoma/ghc,ml9951/ghc,spacekitteh/smcghc,siddhanathan/ghc,jstolarek/ghc,gcampax/ghc,da-x/ghc,fmthoma/ghc,green-haskell/ghc,gridaphobe/ghc,TomMD/ghc,GaloisInc/halvm-ghc,ml9951/ghc,bitemyapp/ghc,ghc-android/ghc,forked-upstream-packages-for-ghcjs/ghc,vTurbine/ghc,vikraman/ghc,siddhanathan/ghc,ml9951/ghc,holzensp/ghc,AlexanderPankiv/ghc,tjakway/ghcjvm,shlevy/ghc,nkaretnikov/ghc,GaloisInc/halvm-ghc,nushio3/ghc,fmthoma/ghc,sgillespie/ghc,mfine/ghc,snoyberg/ghc,lukexi/ghc,sdiehl/ghc,anton-dessiatov/ghc,fmthoma/ghc,mfine/ghc,jstolarek/ghc,mettekou/ghc,siddhanathan/ghc,GaloisInc/halvm-ghc,tjakway/ghcjvm,snoyberg/ghc,mfine/ghc,forked-upstream-packages-for-ghcjs/ghc,vTurbine/ghc,green-haskell/ghc,anton-dessiatov/ghc,da-x/ghc,bitemyapp/ghc,oldmanmike/ghc,TomMD/ghc,tjakway/ghcjvm,mettekou/ghc,sdiehl/ghc,anton-dessiatov/ghc,da-x/ghc,spacekitteh/smcghc,AlexanderPankiv/ghc,nkaretnikov/ghc,bitemyapp/ghc,ghc-android/ghc,wxwxwwxxx/ghc,ezyang/ghc,nushio3/ghc,acowley/ghc,nkaretnikov/ghc,tjakway/ghcjvm,anton-dessiatov/ghc,holzensp/ghc,wxwxwwxxx/ghc,christiaanb/ghc,nathyong/microghc-ghc,ml9951/ghc,forked-upstream-packages-for-ghcjs/ghc,oldmanmike/ghc,lukexi/ghc,anton-dessiatov/ghc,sgillespie/ghc,sdiehl/ghc,gridaphobe/ghc,oldmanmike/ghc,mcschroeder/ghc,mcschroeder/ghc,holzensp/ghc,olsner/ghc,ml9951/ghc,olsner/ghc,siddhanathan/ghc,spacekitteh/smcghc,christiaanb/ghc,mettekou/ghc,sdiehl/ghc,gridaphobe/ghc,jstolarek/ghc,vikraman/ghc,lukexi/ghc,olsner/ghc,mcschroeder/ghc,wxwxwwxxx/ghc,sdiehl/ghc,urbanslug/ghc,sgillespie/ghc,elieux/ghc,gcampax/ghc,urbanslug/ghc,olsner/ghc,ghc-android/ghc,gcampax/ghc,TomMD/ghc,AlexanderPankiv/ghc,mcschroeder/ghc,AlexanderPankiv/ghc,nathyong/microghc-ghc,green-haskell/ghc,mettekou/ghc,TomMD/ghc,ezyang/ghc,green-haskell/ghc,shlevy/ghc,shlevy/ghc,nathyong/microghc-ghc,vikraman/ghc,bitemyapp/ghc