summaryrefslogtreecommitdiff
path: root/openbsd-compat/bsd-misc.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2004-06-25 14:03:34 +1000
committerDarren Tucker <dtucker@zip.com.au>2004-06-25 14:03:34 +1000
commit60bd4098f64fd0fbbd9b6b4de2562623318141a0 (patch)
tree7dc6caa88aa1c03ed6a760855c48f24a0c5570cb /openbsd-compat/bsd-misc.c
parentef3b47a73adf98a510200daea9ebfceebed5bed6 (diff)
- (dtucker) [configure.ac openbsd-compat/misc.c [openbsd-compat/misc.h]
Add closefrom() for platforms that don't have it. (might need some tuning later, but I want to be able to test reexec).
Diffstat (limited to 'openbsd-compat/bsd-misc.c')
-rw-r--r--openbsd-compat/bsd-misc.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 7b06786f..c58cce0f 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -17,7 +17,7 @@
#include "includes.h"
#include "xmalloc.h"
-RCSID("$Id: bsd-misc.c,v 1.21 2004/02/17 05:49:55 djm Exp $");
+RCSID("$Id: bsd-misc.c,v 1.22 2004/06/25 04:03:34 dtucker Exp $");
/*
* NB. duplicate __progname in case it is an alias for argv[0]
@@ -192,6 +192,22 @@ tcsendbreak(int fd, int duration)
}
#endif /* HAVE_TCSENDBREAK */
+#ifndef HAVE_CLOSEFROM
+int
+closefrom(int fd)
+{
+ int i, result = 0, err = 0;
+
+ for (i = fd; i < 128; i++)
+ if (close(i) != 0) {
+ err = errno;
+ result = -1;
+ }
+ errno = err;
+ return result;
+}
+#endif /* HAVE_CLOSEFROM */
+
mysig_t
mysignal(int sig, mysig_t act)
{