EventLog: Loop fwrite if necessary during flush
EventLog: Loop fwrite if necessary during flush

Previously the eventlog flush code would fail if `fwrite` wrote less
than the requested amount. Like all Unix stream I/O operations, however,
`fwrite` isn't guaranteed to write the entire buffer. Here we loop as
long as `fwrite` succeeds in writing anything.

Fixes #11041.

Test Plan: Validate with eventlog

Reviewers: austin, simonmar

Reviewed By: simonmar

Subscribers: thomie

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

GHC Trac Issues: #11041

mcschroeder/ghc,elieux/ghc,da-x/ghc,elieux/ghc,nushio3/ghc,gridaphobe/ghc,elieux/ghc,vTurbine/ghc,tjakway/ghcjvm,shlevy/ghc,shlevy/ghc,GaloisInc/halvm-ghc,AlexanderPankiv/ghc,ezyang/ghc,elieux/ghc,tjakway/ghcjvm,nushio3/ghc,gridaphobe/ghc,vTurbine/ghc,sdiehl/ghc,snoyberg/ghc,tjakway/ghcjvm,sgillespie/ghc,gridaphobe/ghc,sgillespie/ghc,vikraman/ghc,snoyberg/ghc,mcschroeder/ghc,AlexanderPankiv/ghc,AlexanderPankiv/ghc,ezyang/ghc,vTurbine/ghc,sdiehl/ghc,sdiehl/ghc,GaloisInc/halvm-ghc,sdiehl/ghc,sdiehl/ghc,oldmanmike/ghc,vikraman/ghc,oldmanmike/ghc,sgillespie/ghc,da-x/ghc,AlexanderPankiv/ghc,gridaphobe/ghc,gridaphobe/ghc,sgillespie/ghc,ezyang/ghc,vTurbine/ghc,oldmanmike/ghc,oldmanmike/ghc,oldmanmike/ghc,snoyberg/ghc,AlexanderPankiv/ghc,snoyberg/ghc,elieux/ghc,vikraman/ghc,vTurbine/ghc,vTurbine/ghc,olsner/ghc,GaloisInc/halvm-ghc,vTurbine/ghc,mettekou/ghc,nushio3/ghc,AlexanderPankiv/ghc,sgillespie/ghc,shlevy/ghc,mcschroeder/ghc,vikraman/ghc,sgillespie/ghc,nushio3/ghc,sdiehl/ghc,shlevy/ghc,da-x/ghc,olsner/ghc,nushio3/ghc,vikraman/ghc,olsner/ghc,mettekou/ghc,tjakway/ghcjvm,shlevy/ghc,snoyberg/ghc,ezyang/ghc,mcschroeder/ghc,da-x/ghc,mettekou/ghc,nushio3/ghc,shlevy/ghc,olsner/ghc,mettekou/ghc,mcschroeder/ghc,sgillespie/ghc,olsner/ghc,tjakway/ghcjvm,ezyang/ghc,ezyang/ghc,shlevy/ghc,mettekou/ghc,elieux/ghc,AlexanderPankiv/ghc,da-x/ghc,vikraman/ghc,GaloisInc/halvm-ghc,olsner/ghc,olsner/ghc,elieux/ghc,mcschroeder/ghc,nushio3/ghc,oldmanmike/ghc,mcschroeder/ghc,oldmanmike/ghc,da-x/ghc,snoyberg/ghc,ezyang/ghc,mettekou/ghc,GaloisInc/halvm-ghc,vikraman/ghc,gridaphobe/ghc,tjakway/ghcjvm,tjakway/ghcjvm,GaloisInc/halvm-ghc,snoyberg/ghc,da-x/ghc,GaloisInc/halvm-ghc,gridaphobe/ghc,sdiehl/ghc,mettekou/ghc