Back to libut API Reference


    #include "libut/ut.h"
    int UT_fd_unreg(int fd);


This function un-registers file descriptor fd. The libut event loop will no longer monitor whether it is readable or writable and make callbacks when those things occur.

The file descriptor must have been previously registered using UT_fd_reg(3) or the higher-level function UT_net_connect(3).

Generally, this function is used immediately in sequence with close(fd);.


This function returns 0 on success. If the file descriptor is not registered to begin with, it returns -1 to indicate error.


If this function is invoked after the libut event loop has detected fd is readable or writable but before its callback has been invoked (in other words, the callback for file descriptor A runs first and unregisters file descriptor B which has a callback of its own pending), that final callback for fd (B) will still occur because its readable or writable status was detected prior to the unregistration. (It seems unlikely that any real program would behave this way).


UT_fd_reg(3), UT_fd_write(3), UT_fd_cntl(3), UT_fd_get_aux(3)


Troy D. Hanson <>