#include "para.h"
+#include "error.h"
/**
* check whether a file exists
*
return !stat(fn, &statbuf);
}
+
+int para_select(int n, fd_set *readfds, fd_set *writefds,
+ struct timeval *timeout)
+{
+ int ret, err;
+ do {
+ ret = select(n, readfds, writefds, NULL, timeout);
+ err = errno;
+ } while (ret < 0 && errno == EINTR);
+ if (ret < 0)
+ PARA_CRIT_LOG("select error (%s)\n", strerror(err));
+ return ret;
+}
+
+int mark_fd_nonblock(int fd)
+{
+ int flags = fcntl(fd, F_GETFL);
+ if (flags < 0)
+ return -E_F_GETFL;
+ if (fcntl(fd, F_SETFL, ((long)flags) | O_NONBLOCK) < 0)
+ return -E_F_SETFL;
+ return 1;
+}
+