procutil: introduce context-manager interface for protect/restorestdio
The code looks slightly cleaner since it was pretty easy to pass arguments
in wrong order.
commandserver: rewrite protectio/restoreio to not depend on ui
Prepares for porting to utils.procutil, in which ui shouldn't be known.
ui.flush() is replaced with ui.fout.flush() since ui.ferr wasn't involved.