The code in the touch function of sd-readahead.c: for (;;) { if (close(fd) >= 0) break; if (errno != EINTR) return -errno; } The ultra-paranoid ultra portable correct code: /* * The state of a file descriptor after close gives an EINTR error * is unspecified by POSIX so this function avoids the problem by * simply blocking all signals. */ int errnum; sigset_t sigset; /* First use the signal set for the full set */ sigfillset(&sigset); pthread_sigmask(SIG_BLOCK, &sigset, &sigset); /* Then reuse the signal set for the old set */ if (-1 == close(fd)) { errnum = errno; assert(errnum != 0); } else { errnum = 0; } pthread_sigmask(SIG_SETMASK, &sigset, NULL); return errnum; The system specific but mostly standard code you probably want: int errnum; if (-1 == close(fd)) { errnum = errno; assert(errnum != 0); /* On Linux and probably most platforms EINTR can't happen or * would close the file succesfully anyways. */ if (EINTR == errnum) { errnum = 0; } } else { errnum = 0; } return errnum;
Curiously enough, it's the open that would probably be the actual function that one might want to retry on EINTR for (it can block interruptibly on fifos and devices). It probably wouldn't be a problem in practise though.
We removed readahead.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.