summaryrefslogtreecommitdiffstats
path: root/openbsd-compat
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
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')
-rw-r--r--openbsd-compat/bsd-misc.c18
-rw-r--r--openbsd-compat/bsd-misc.h6
2 files changed, 22 insertions, 2 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)
{
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h
index 009739b1..7027815d 100644
--- a/openbsd-compat/bsd-misc.h
+++ b/openbsd-compat/bsd-misc.h
@@ -1,4 +1,4 @@
-/* $Id: bsd-misc.h,v 1.15 2004/03/08 11:59:03 dtucker Exp $ */
+/* $Id: bsd-misc.h,v 1.16 2004/06/25 04:03:34 dtucker Exp $ */
/*
* Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org>
@@ -93,6 +93,10 @@ int tcsendbreak(int, int);
void unsetenv(const char *);
#endif
+#ifndef HAVE_CLOSEFROM
+int closefrom(int);
+#endif
+
/* wrapper for signal interface */
typedef void (*mysig_t)(int);
mysig_t mysignal(int sig, mysig_t act);