Linux cgi-停止读取输入

Linux cgi-停止读取输入,linux,timer,cgi,Linux,Timer,Cgi,我已经尝试通过cgi脚本在上表示鼠标移动。 我试过这个: file=fopen(MOUSEFILE, "r"); while((fread( &ie, sizeof(struct input_event),1,file)==0) && (i<1000)){i++;} fclose(file); if(i==1000){ printf("<IMG SRC=\"../images/mouse.bmp\">"); }else{ if(ie.ty

我已经尝试通过cgi脚本在上表示鼠标移动。 我试过这个:

file=fopen(MOUSEFILE, "r"); 
while((fread( &ie, sizeof(struct input_event),1,file)==0) && (i<1000)){i++;} 
fclose(file);

if(i==1000){
  printf("<IMG SRC=\"../images/mouse.bmp\">"); 
}else{
  if(ie.type==2 && ie.code==0 && ie.value==-1){
    printf("<IMG SRC=\"../images/left.bmp\"");
  }else if(ie.type==2 && ie.code==0 && ie.value==1){
    printf("<IMG SRC=\"../images/right.bmp\"");
  }else if(ie.type==1 && ie.code==272 && ie.value==1){
    printf("<IMG SRC=\"../images/pressed.bmp\">");
  }
}
file=fopen(MOUSEFILE,“r”);
而((fread(&ie,sizeof(struct-input_-event),1,file)==0)和&(i找到了一个解决方法:

file = open(MOUSEFILE, O_RDONLY | O_NDELAY);
while(  (1>read(file, &ie, sizeof(struct input_event))) && (i<50000)  ){i++;}
close(file);
if(i==50000){
  printf("<IMG SRC=\"../images/mouse.bmp\">"); 
}else{ ...
file=open(MOUSEFILE,O|RDONLY | O|NDELAY);
而((1>读取(文件,&ie,sizeof(结构输入事件))&&(i)