Re: [PATCH 01/10] Add handle_eintr to wrap EINTR handling in syscalls

Kamil Rytarowski
2020-09-03T21:13:32Z

[-- Attachment #1.1: Type: text/plain, Size: 1048 bytes --]

On 03.09.2020 16:17, Tom Tromey wrote:
>>>>>> "Kamil" == Kamil Rytarowski <n54@gmx.com> writes:
>
> Kamil> +2020-03-17 Kamil Rytarowski <n54@gmx.com>
> Kamil> +
> Kamil> + * eintr.h: Add handle_eintr.
>
> Kamil> +template <typename Fun, typename... Args>
> Kamil> +inline decltype (auto) handle_eintr (const Fun &F, const Args &... A)
>
> I like this, but from what I read it seems that "decltype(auto)" is
> C++14 -- but gdb is still C++11.
>

OK, I have downgraded this to C++11.

>
> Kamil> +{
> Kamil> + decltype (F (A...)) ret;
> Kamil> + do
> Kamil> + {
> Kamil> + errno = 0;
> Kamil> + ret = F (A...);
> Kamil> + }
> Kamil> + while (ret == -1 && errno == EINTR);
>
> Also this seems to assume that "ret" is comparable to an int anyway.
> So maybe just assuming int everywhere would be ok.
>

This assumption is not always valid, e.g. read(2) returns ssize_t.

I've added in the template flexibility of the returned type as it could
be e.g. nullptr for fopen(3).

> Tom
>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]