Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Assuming all I/O failures are EINTR is really, really odd, as if to say disks never fill up or fail and sockets never disconnect.

The point is to retry on EINTR and to abort completely in case of other IO failures.

    assert(errno == EINTR);
    continue;
is equivalent to

    if (errno == EINTR)
        continue;
    abort();
> But somebody somewhere is reading this and thinking this is a "semantically correct pattern" (as it is introduced) and may just copy-paste it into their program.

Even if they do, it likely will not actually do any harm, it'll just kill the program instead of gracefully handle error.



You are wrong. assert is a no-op when NDEBUG is defined. Some compilers will set that for you in an optimized build.

Using an assert in place of real error checking or otherwise relying on its side effects is consequently a huge wtf in C.


More like, assert() from assert.h is a huge wtf in C, because turning asserts off in optimized builds produces exactly these kinds of scenarios.


ENOSPC ?


Is something the author very specifically noted he does not care about in his examples a bit later:

> I don’t care about a “disk full” that I could catch and act on




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: