From: Lennart Poettering Date: Thu, 28 Jan 2010 00:53:15 +0000 (+0100) Subject: add non-failing close() variant X-Git-Tag: v1~776 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=85f136b5d09168a7e4fd2ad27ef81dbe2d356c07 add non-failing close() variant --- diff --git a/util.c b/util.c index 56f53eafd..38ed74fbc 100644 --- a/util.c +++ b/util.c @@ -97,6 +97,14 @@ int close_nointr(int fd) { } } +void close_nointr_nofail(int fd) { + + /* like close_nointr() but cannot fail, and guarantees errno + * is unchanged */ + + assert_se(close_nointr(fd) == 0); +} + int parse_boolean(const char *v) { assert(v); diff --git a/util.h b/util.h index 9aceaef47..c3d3aad7b 100644 --- a/util.h +++ b/util.h @@ -61,6 +61,7 @@ bool endswith(const char *s, const char *postfix); bool startswith(const char *s, const char *prefix); int close_nointr(int fd); +void close_nointr_nofail(int fd); int parse_boolean(const char *v);