]> git.tuebingen.mpg.de Git - paraslash.git/blob - fd.c
introduce para_select()
[paraslash.git] / fd.c
1 #include "para.h"
2 /**
3  * check whether a file exists
4  *
5  * \param fn the file name
6  *
7  * \return Non-zero iff file exists.
8  */
9 int file_exists(const char *fn)
10 {
11         struct stat statbuf;
12
13         return !stat(fn, &statbuf);
14 }
15
16 int para_select(int n, fd_set *readfds, fd_set *writefds,
17                 struct timeval *timeout)
18 {
19         int ret, err;
20         do {
21                 ret = select(n, readfds, writefds, NULL, timeout);
22                 err = errno;
23         } while (ret < 0 && errno == EINTR);
24         if (ret < 0)
25                 PARA_CRIT_LOG("select error (%s)\n", strerror(err));
26         return ret;
27 }