#include #include #include void write_pipe1(int fd,int code){ fd_set wrfds; struct timeval tv; /* Watch stdin (fd 0) to see when it has input. */ FD_ZERO(&wrfds); FD_SET(fd, &wrfds); tv.tv_sec = 0; tv.tv_usec = 0; //retval = select(keyb_fifo_put+1, &rfds, NULL, NULL, &tv); select(fd+1, NULL, &wrfds, NULL, &tv); if( FD_ISSET(fd, &wrfds) ){ write(fd, &code,4); printf("+"); } else { printf("-"); } } void write_pipe2(int fd,int code){ if(write(fd, &code,4)==4){ printf("+"); } else { printf("-"); } } int main(){ int temp[2]; int i; if(pipe(temp)!=0) printf("Error"); for(i=0;i<20;i++){ write_pipe1(temp[1],0x20); } printf("\n"); read(temp[0],&i,4); for(i=0;i<20;i++){ write_pipe1(temp[1],0x20); } printf("\n"); read(temp[0],&i,4); for(i=0;i<2048;i++){ write_pipe2(temp[1],0x20); if(i%60==59) printf("\n"); } printf("\n"); }