summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/util.c10
-rw-r--r--src/shared/util.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 0eca4f8562..dc05001a28 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1696,3 +1696,13 @@ int execute_command(const char *command, char *const argv[]) {
}
}
+
+void cmsg_close_all(struct msghdr *mh) {
+ struct cmsghdr *cmsg;
+
+ assert(mh);
+
+ for (cmsg = CMSG_FIRSTHDR(mh); cmsg; cmsg = CMSG_NXTHDR(mh, cmsg))
+ if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS)
+ close_many((int*) CMSG_DATA(cmsg), (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int));
+}
diff --git a/src/shared/util.h b/src/shared/util.h
index 9458a1942f..e9d9df1386 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -485,3 +485,5 @@ union inotify_event_buffer {
struct inotify_event ev;
uint8_t raw[INOTIFY_EVENT_MAX];
};
+
+void cmsg_close_all(struct msghdr *mh);