--- honeyd.c.orig	2009-10-29 20:51:37.000000000 +0100
+++ honeyd.c	2009-10-29 20:53:14.000000000 +0100
@@ -32,6 +32,7 @@
 
 #include <sys/param.h>
 #include <sys/types.h>
+#include <limits.h>
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -450,7 +451,7 @@
 
 	/* Raising file descriptor limits */
 	rl.rlim_max = RLIM_INFINITY;
-	rl.rlim_cur = RLIM_INFINITY;
+	rl.rlim_cur = ( OPEN_MAX < RLIM_INFINITY) ? OPEN_MAX : RLIM_INFINITY ;
 	if (setrlimit(RLIMIT_NOFILE, &rl) == -1) {
 		/* Linux does not seem to like this */
 		if (getrlimit(RLIMIT_NOFILE, &rl) == -1)