diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-08-21 16:13:15 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-08-21 17:24:21 +0200 |
commit | a9f85faf43ae2289e19ba9105c36496aefe66072 (patch) | |
tree | 842eaf0002e947473be9274327008a8e52f69d50 | |
parent | 11adc1aef7a1a6e9ba3fda8eb34eb5fadedc0385 (diff) |
util: simplify close_nointr() a bit
-rw-r--r-- | src/shared/util.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index 9d254e0464..a54e879953 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -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) { |