21,595
社区成员
发帖
与我相关
我的任务
分享
struct sigaction saio; /* definition of signal action */
/* install the signal handler before making the device asynchronous */
saio.sa_handler = signal_handler_IO;
//saio.sa_mask = 0;
saio.sa_flags = 0;
saio.sa_restorer = NULL;
sigaction(SIGIO,&saio,NULL);
/* allow the process to receive SIGIO */
fcntl(fd0, F_SETOWN,gettid());
/* Make the file descriptor asynchronous (the manual page says only
O_APPEND and O_NONBLOCK, will work with F_SETFL...) */
fcntl(fd0, F_SETFL, FASYNC);
#include <sys/types.h>
#include <pthread.h>
#include <sys/syscall.h>
pid_t gettid()
{
return syscall(SYS_gettid);
}