From 7c0393e894498e177698a0cf10ad802f71a4c4a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sun, 3 Mar 2024 18:59:57 +0100 Subject: [PATCH] Clean up with_stdin_at error handling --- src/fd.hpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/fd.hpp b/src/fd.hpp index 7cb343f..48ac48b 100644 --- a/src/fd.hpp +++ b/src/fd.hpp @@ -15,15 +15,11 @@ int with_stdin_at(int fd, F && what) { quickscope_wrapper stdin_saved_deleter{[=] { close(stdin_saved); }}; dup2(fd, 0); - clearerr(stdin); - if(int ret = what()) { - dup2(stdin_saved, 0); - return ret; - } + int ret = what(); dup2(stdin_saved, 0); - return 0; + return ret; } /// with_len may not exceed pipe capacity (64k by default)