I want to redirect cout to a file. We have an assign operator for cout, but it doesn't work, and the source iostream.cc says it's not really supported. So how do you make this work portably? There is no cout.close(). Should I use dup2 on the underlying fd?