>>144 (>>168)
>>161-162 がダメだったということは、多分これもうまくいかないんだろうけど
#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>

int is_enter_pressed(void)
{
int fd_flag, ret=0;
char buf[10];

fd_flag=fcntl(0, F_GETFL);
fcntl(0, F_SETFL, O_NONBLOCK);
while(read(0, buf, sizeof(buf))>0) /* 不要な入力はすべて読み飛ばす */
ret=1;
fcntl(0, F_SETFL, fd_flag);

return ret;
}

int main(void){
int i;
printf("Enter を押すと途中で終了します\n");
for(i=0;i<30;i++){
if(is_enter_pressed()) break;
printf("%s %d ある処理\n", __FUNCTION__, i);
sleep(1);
}
return 0;
}