This is an archive of the discontinued LLVM Phabricator instance.

Clear errno before calling the function in RetryAfterSignal.
ClosedPublic

Authored by ricky on Jun 28 2018, 11:33 PM.

Details

Summary

For certain APIs, the return value of the function does not distinguish
between failure (which populates errno) and other non-error conditions
(which do not set errno).

For example, fgets returns NULL both when an error has occurred, or upon
EOF. If errno is already EINTR for whatever reason, then

RetryAfterSignal(nullptr, fgets, ...);

on a stream that has reached EOF would infinite loop.

Fix this by setting errno to 0 before each attempt in RetryAfterSignal.

Diff Detail

Repository
rL LLVM

Event Timeline

ricky created this revision.Jun 28 2018, 11:33 PM
chandlerc accepted this revision.Jul 6 2018, 7:10 PM

Thanks, this is obviously correct. Do you have commit access or do you need someone to land this for you?

This revision is now accepted and ready to land.Jul 6 2018, 7:10 PM
ricky added a comment.Jul 6 2018, 7:19 PM

I don't have commit access, so would be great if you could land it - thanks!

Ricky

This revision was automatically updated to reflect the committed changes.