timeoutread.h (366B)
1 #ifndef TIMEOUTREAD_H 2 #define TIMEOUTREAD_H 3 4 #include <sys/types.h> 5 6 extern ssize_t timeoutread(int t, int fd, char *buf, size_t len); 7 8 #define GEN_SAFE_TIMEOUTREAD(funcname,tout,readfd,doexit) \ 9 ssize_t funcname(int fd, void *buf, size_t len) \ 10 { \ 11 ssize_t r; \ 12 r = timeoutread(tout,readfd,buf,len); \ 13 if (r == 0 || r == -1) doexit; \ 14 return r; \ 15 } 16 17 #endif