chiark / gitweb /
add non-failing close() variant
authorLennart Poettering <lennart@poettering.net>
Thu, 28 Jan 2010 00:53:15 +0000 (01:53 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 28 Jan 2010 00:53:15 +0000 (01:53 +0100)
util.c
util.h

diff --git a/util.c b/util.c
index 56f53eafd66caf1872c5e4d9954bb1a84c0177a3..38ed74fbcb531a170a7dfd06bd11960b13bffe37 100644 (file)
--- 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);
 
 int parse_boolean(const char *v) {
         assert(v);
 
diff --git a/util.h b/util.h
index 9aceaef47fd5e118d3a8a9a811fbf036b3cf944a..c3d3aad7b9a24d7ccc652ed09167da9500213966 100644 (file)
--- 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);
 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);
 
 
 int parse_boolean(const char *v);