common: improve redirect_output() error handling