views:

14

answers:

1
  • I got a lot of EINTR errors when I used the following function in my program. Why couldn't the program resume to receive data using the loop when EINTR happened? What are the possible causes of EINTR error number under cygwin?

    int Recv(int fd, void *buf, int size, int flags) {

    int over = 0;
    
    
    int res = 0;
    while (over < size) {
        res = recv(fd, (char *)buf+over, size-over, flags);
        if (res < 0) {
            if(errno != EINTR)
               return res;
        }else
            over += res;
    }
    return over;
    

    }

A: 

As the POSIX spec says regarding EINTR: "The recv() function was interrupted by a signal that was caught, before any data was available". If you get it without any signals having been caught, you might want to report that to the Cygwin mailing list.

ak2