Fix #1185: restart the IO manager after fork()
Fix #1185: restart the IO manager after fork()

This is the libraries/base part of the patch; there is a corresponding
patch to GHC itself.

The main change is that we now keep track of the IO manager's ThreadId
in a top-level MVar, and ensureIOManagerIsRunning checks whether a
previous IO manager thread is alive before starting one.  In the child
of fork(), we can hence call ensureIOManagerIsRunning to restart the
IO manager.

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