Clean up with_stdin_at error handling

This commit is contained in:
наб 2024-03-03 18:59:57 +01:00
parent 2118cc3679
commit 7c0393e894
No known key found for this signature in database
GPG Key ID: BCFD0B018D2658F1

View File

@ -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)