flush stdout and stderr