Save stdout, stderr also in case of exception.