+2008-01-21 Guillem Jover <guillem@debian.org>
+
+ * configure.ac (AC_CHECK_FUNCS): Add getdtablesize.
+ * utils/start-stop-daemon.c (get_open_fd_max): New function.
+ (main) [OShpux]: Remove.
+ [!OShpux]: Use get_open_fd_max instead of hardcoded getdtablesize.
+
2008-01-21 Guillem Jover <guillem@debian.org>
* man/start-stop-daemon.8: Fix quotation to get rid of a spurious
# Checks for library functions.
DPKG_FUNC_VA_COPY
AC_CHECK_FUNCS([vsnprintf snprintf strerror strsignal scandir alphasort])
-AC_CHECK_FUNCS([unsetenv lchown setsid bcopy isascii memcpy])
+AC_CHECK_FUNCS([unsetenv lchown setsid bcopy isascii memcpy getdtablesize])
SJR_COMPILER_WARNINGS
SJR_COMPILER_OPTIMISATIONS
if (gettimeofday(tv, NULL) != 0)
fatal("gettimeofday failed: %s", strerror(errno));
}
+static long
+get_open_fd_max(void)
+{
+#ifdef HAVE_GETDTABLESIZE
+ return getdtablesize();
+#else
+ return sysconf(_SC_OPEN_MAX);
+#endif
+}
static void
daemonize(void)
dup2(devnull_fd, 0); /* stdin */
dup2(devnull_fd, 1); /* stdout */
dup2(devnull_fd, 2); /* stderr */
-#if defined(OShpux)
- /* Now close all extra fds */
- for (i = sysconf(_SC_OPEN_MAX) - 1; i >= 3; --i)
- close(i);
-#else
+
/* Now close all extra fds */
- for (i = getdtablesize() - 1; i >= 3; --i)
+ for (i = get_open_fd_max() - 1; i >= 3; --i)
close(i);
-#endif
}
execv(startas, argv);
fatal("Unable to start %s: %s", startas, strerror(errno));