// for compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
-#ifdef wxUSE_EPOLL_DISPATCHER
+#if wxUSE_EPOLL_DISPATCHER
 
 #include "wx/unix/private/epolldispatcher.h"
 #include "wx/unix/private.h"
 
 #include <sys/epoll.h>
 #include <errno.h>
+#include <unistd.h>
 
 #define wxEpollDispatcher_Trace wxT("epolldispatcher")
 
     m_epollDescriptor = epollDescriptor;
 }
 
+wxEpollDispatcher::~wxEpollDispatcher()
+{
+    if ( close(m_epollDescriptor) != 0 )
+    {
+        wxLogSysError(_("Error closing epoll descriptor"));
+    }
+}
+
 bool wxEpollDispatcher::RegisterFD(int fd, wxFDIOHandler* handler, int flags)
 {
     epoll_event ev;