#include <sys/types.h>
#include <dirent.h>
#include <sys/mman.h>
+#include <poll.h>
#include "para.h"
#include "error.h"
* \return positive if fd is ready for writing, zero if it isn't, negative if
* an error occurred.
*/
-
int write_ok(int fd)
{
- fd_set wfds;
+ int ret;
+ struct pollfd pfd = {.fd = fd, .events = POLLOUT};
- FD_ZERO(&wfds);
- FD_SET(fd, &wfds);
- return para_select(fd + 1, NULL, &wfds, 0);
+ do
+ ret = poll(&pfd, 1, 0);
+ while (ret < 0 && errno == EINTR);
+ if (ret < 0)
+ return -ERRNO_TO_PARA_ERROR(errno);
+ return pfd.revents & POLLOUT;
}
/**