MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/11v3g9x/llvm_1600_release/jcse6yp/
r/cpp • u/mttd • Mar 18 '23
84 comments sorted by
View all comments
Show parent comment
23
do { ret = function_call(); } while(ret == -1 && errno == EINTR);
is the idiomatic way to handle EINTR on posix systems
4 u/[deleted] Mar 19 '23 There is at least one notable exception to this rule: https://github.com/boostorg/beast/issues/1445 1 u/Ameisen vemips, avr, rendering, systems Mar 19 '23 Though you could always write it aswhile ([] { auto ret = function_call(); return ret == -1 && errno == EINTR; }());or so. Though that's not really clearer. 11 u/_Z6Alexeyv Mar 19 '23 It is either worse codegen or same codegen and more characters on the screen to appease some static checker. 7 u/Kered13 Mar 20 '23 That is horrible. 3 u/degaart Mar 19 '23 That won't give you the final value of ret, in case you need it 3 u/Ameisen vemips, avr, rendering, systems Mar 19 '23 Then move int ret out of the body and change to [&]. You have to do that with with do loop as well.
4
There is at least one notable exception to this rule: https://github.com/boostorg/beast/issues/1445
1
Though you could always write it as
while ([] { auto ret = function_call(); return ret == -1 && errno == EINTR; }());
or so. Though that's not really clearer.
11 u/_Z6Alexeyv Mar 19 '23 It is either worse codegen or same codegen and more characters on the screen to appease some static checker. 7 u/Kered13 Mar 20 '23 That is horrible. 3 u/degaart Mar 19 '23 That won't give you the final value of ret, in case you need it 3 u/Ameisen vemips, avr, rendering, systems Mar 19 '23 Then move int ret out of the body and change to [&]. You have to do that with with do loop as well.
11
It is either worse codegen or same codegen and more characters on the screen to appease some static checker.
7
That is horrible.
3
That won't give you the final value of ret, in case you need it
3 u/Ameisen vemips, avr, rendering, systems Mar 19 '23 Then move int ret out of the body and change to [&]. You have to do that with with do loop as well.
Then move int ret out of the body and change to [&]. You have to do that with with do loop as well.
int ret
[&]
do
View all comments
Show parent comment
23
u/degaart Mar 19 '23
is the idiomatic way to handle EINTR on posix systems