[master] 8aedf4b Add a closefd(int*) macro to properly dispose of file descriptors
Poul-Henning Kamp
phk at FreeBSD.org
Sat Jan 14 20:18:05 CET 2017
commit 8aedf4bd4b2b0a4484138c01c9a0293b53fb9ec8
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sat Jan 14 19:13:02 2017 +0000
Add a closefd(int*) macro to properly dispose of file descriptors
diff --git a/include/vdef.h b/include/vdef.h
index 892eda6..f0afe09 100644
--- a/include/vdef.h
+++ b/include/vdef.h
@@ -49,6 +49,13 @@
< sizeof buf); \
} while (0)
+/* Close and discard filedescriptor */
+#define closefd(fdp) \
+ do { \
+ assert(*(fdp) >= 0); \
+ AZ(close(*(fdp))); \
+ *(fdp) = -1; \
+ } while (0)
#ifndef __GNUC_PREREQ
# if defined __GNUC__ && defined __GNUC_MINOR__
More information about the varnish-commit
mailing list