文章链接:https://codemouse.online/archives/765434567890
设置非阻塞
#include<stdio.h>
#include<sys/types.h>
#include <fcntl.h>
#include<unistd.h>
int setnonblocking(int fd)
{
int old_option = fcntl(fd, F_GETFL);
int new_option = old_option | O_NONBLOCK;
fcntl(fd, F_SETFL, new_option);
return old_option;
}