From 4f3fb6e44500d6ce4781fbed8d547f6a7891fc66 Mon Sep 17 00:00:00 2001 From: "Anthony G. Basile" Date: Wed, 18 Mar 2015 15:07:54 -0400 Subject: shared: import close_many() from upstream Signed-off-by: Anthony G. Basile --- src/shared/util.c | 9 +++++++++ src/shared/util.h | 2 ++ 2 files changed, 11 insertions(+) (limited to 'src/shared') diff --git a/src/shared/util.c b/src/shared/util.c index dc05001a28..f68b687006 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -232,6 +232,15 @@ int safe_close(int fd) { return -1; } +void close_many(const int fds[], unsigned n_fd) { + unsigned i; + + assert(fds || n_fd <= 0); + + for (i = 0; i < n_fd; i++) + safe_close(fds[i]); +} + int unlink_noerrno(const char *path) { PROTECT_ERRNO; int r; diff --git a/src/shared/util.h b/src/shared/util.h index e9d9df1386..55701cf7a5 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -138,6 +138,8 @@ char *endswith(const char *s, const char *postfix) _pure_; int close_nointr(int fd); int safe_close(int fd); +void close_many(const int fds[], unsigned n_fd); + int parse_uid(const char *s, uid_t* ret_uid); #define parse_gid(s, ret_uid) parse_uid(s, ret_uid) -- cgit v1.2.3-54-g00ecf