diff --git a/configure b/configure
index 9aa6cc7e2e1dd6f00cabdc93b561b08c8344d8ff..5c668a1c992629fc138880ad4ffa553082045511 100755
--- a/configure
+++ b/configure
@@ -15636,7 +15636,11 @@ cat >>conftest.$ac_ext <<_ACEOF
 int
 main ()
 {
-epoll_create(10);
+int res = epoll_create(10);
+					  if (res < 0)
+					     return 1;
+					  close (res);
+					  return 0;
   ;
   return 0;
 }
diff --git a/configure.ac b/configure.ac
index 40ee8c11f496c2bd29d1a5c713efbd5c08a3ce97..a1862937b3a2e06dc10dc2f5e5265e9ba8fcddf8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -334,7 +334,11 @@ AST_C_DEFINE_CHECK([PTHREAD_RWLOCK_PREFER_WRITER_NP], [PTHREAD_RWLOCK_PREFER_WRI
 
 AC_MSG_CHECKING(for working epoll support)
 AC_LINK_IFELSE(
-AC_LANG_PROGRAM([#include <sys/epoll.h>], [epoll_create(10);]),
+AC_LANG_PROGRAM([#include <sys/epoll.h>], [int res = epoll_create(10);
+					  if (res < 0)
+					     return 1;
+					  close (res);
+					  return 0;]),
 AC_MSG_RESULT(yes)
 AC_DEFINE([HAVE_EPOLL], 1, [Define to 1 if your system has working epoll support.]),
 AC_MSG_RESULT(no)