summaryrefslogtreecommitdiffstats
path: root/common.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-05-15 16:09:42 +0000
committerRoy Marples <roy@marples.name>2008-05-15 16:09:42 +0000
commit8dc6afb7e808c5e24a69fd035914a1a67432a950 (patch)
treed2474e4bfb72febc51e88e9c42cc68acb7a2d90f /common.c
parentfca9d5445b39e6efa37de6cf86c99229dfab3167 (diff)
downloaddhcpcd-8dc6afb7e808c5e24a69fd035914a1a67432a950.tar.xz
Check correct lengths and use closefrom where available.
Diffstat (limited to 'common.c')
-rw-r--r--common.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/common.c b/common.c
index 16ef01b1..cad633ee 100644
--- a/common.c
+++ b/common.c
@@ -109,6 +109,20 @@ strlcpy(char *dst, const char *src, size_t size)
}
#endif
+#ifndef HAVE_CLOSEFROM
+int
+closefrom(int fd)
+{
+ int max = getdtablesize();
+ int i;
+ int r = 0;
+
+ for (i = fd; i < max; i++)
+ r += close(i);
+ return r;
+}
+#endif
+
/* Close our fd's */
int
close_fds(void)