     }
     
     public func close() throws {
-#if os(Linux)
-        let res = Glibc.close(self.fd)
-#else
-        let res = Darwin.close(self.fd)
-#endif
-        guard res >= 0 else {
-            throw ioError(errno: errno, function: "close")
+        let _ = try wrapSyscall({ $0 >= 0 }, function: "close") {
+#if os(Linux)
+            return Glibc.close(self.fd)
+#else
+            return Int(Darwin.close(self.fd))
+#endif
         }
     }
 

        ev.events = toEpollEvents(interested: interested)
        ev.data.fd = selectable.descriptor

        let res = CEpoll.epoll_ctl(self.fd, EPOLL_CTL_ADD, selectable.descriptor, &ev)
        guard res == 0 else {
            throw ioError(errno: errno, function: "epoll_ctl")
        }
        registrations[Int(selectable.descriptor)] = Registration(selectable: selectable, attachment: attachment)
#else
        let res = register_kqueue(selectable: selectable, interested: interested)
    
        guard res != -1 else {
            throw ioError(errno: errno, function: "kevent")
        }
        registrations[Int(selectable.descriptor)] = Registration(selectable: selectable, attachment: attachment)
#endif
    }
    
    public func reregister(selectable: Selectable, interested: InterestedEvent) throws {

    

#if !os(Linux)
    private func register_kqueue(selectable: Selectable, interested: InterestedEvent) throws {
        // Allocated on the stack
        var events = (kevent(), kevent())
        
