4 ms·
DJB only sets errno_intr here in error.c int error_intr = #ifdef EINTR EINTR; #else -1; #endif The (errno = error_intr) happens in this block:
by bayareaguy 18y ago
DJB only sets errno_intr here in error.c
int error_intr =
#ifdef EINTR
EINTR;
#else
-1;
#endif
The (errno = error_intr) happens in this block:
default:
for (;;) {
r = read(fdfile,inbuf,sizeof inbuf);
if (r == -1) {
if (errno = error_intr) continue;
_exit(23);
}
if (r == 0)
break;
if (!fetch_ascii)
substdio_put(&ss,inbuf,r);
else
for (i = 0;i < r;++i) {
if (inbuf[i] == '\n')
substdio_put(&ss,"\r",1);
substdio_put(&ss,inbuf + i,1);
}
}
break;
Like a lot of DJB code, it's hard to tell exactly what he's trying to do. He could be trying to deal with some weird platform. Where EINTR is defined to something other than 0 that code will cause the read() to be repeated whenever it returns -1 and when the code eventually gets back to the caller errno will be left set to EINTR. But on platforms where EINTR is 0, a read error will exit.
- pc 18y agoYou're right that this could theoretically be the intent -- but it's very unlikely that it's necessary: "The value of errno is zero at program startup" - ISO/IEC 9899:TC2. If EINTR was 0, there'd be no way of detecting it.