util: simplify close_nointr() a bit

This commit is contained in:
Lennart Poettering 2014-08-21 16:13:15 +02:00
parent 11adc1aef7
commit a9f85faf43

View file

@ -175,25 +175,24 @@ char* first_word(const char *s, const char *word) {
}
int close_nointr(int fd) {
int r;
assert(fd >= 0);
r = close(fd);
if (r >= 0)
return r;
else if (errno == EINTR)
/*
* Just ignore EINTR; a retry loop is the wrong
* thing to do on Linux.
*
* http://lkml.indiana.edu/hypermail/linux/kernel/0509.1/0877.html
* https://bugzilla.gnome.org/show_bug.cgi?id=682819
* http://utcc.utoronto.ca/~cks/space/blog/unix/CloseEINTR
* https://sites.google.com/site/michaelsafyan/software-engineering/checkforeintrwheninvokingclosethinkagain
*/
if (close(fd) >= 0)
return 0;
else
return -errno;
/*
* Just ignore EINTR; a retry loop is the wrong thing to do on
* Linux.
*
* http://lkml.indiana.edu/hypermail/linux/kernel/0509.1/0877.html
* https://bugzilla.gnome.org/show_bug.cgi?id=682819
* http://utcc.utoronto.ca/~cks/space/blog/unix/CloseEINTR
* https://sites.google.com/site/michaelsafyan/software-engineering/checkforeintrwheninvokingclosethinkagain
*/
if (errno == EINTR)
return 0;
return -errno;
}
int safe_close(int fd) {