mirror of
https://git.sr.ht/~nabijaczleweli/tzpfms
synced 2025-04-11 09:30:02 +03:00
Clean up with_stdin_at error handling
This commit is contained in:
parent
2118cc3679
commit
7c0393e894
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user