双重循环实现函数确保调用

#define wrap_call(dtype, x) \
    do { \
        dtype result; \
        do { \
            result = x; \
        } while ((result == -1) && (errno == EINTR)); \
        return result; \
    } while (0)

int accept_noeintr(int socket, struct sockaddr *restrict address,socklen_t *restrict address_len)
{
    wrap_call(int, accept(socket, address, address_len));
}

  

猜你喜欢

转载自www.cnblogs.com/hshy/p/11359907.html