linux下按下键退出while循环(类似于_kbhit)
#include <stdio.h>
#include <sys/select.h>
#include <termios.h>
#include <unistd.h>
#include <ctype.h>
#define STDIN 0
int main()
{
struct timeval tv = {0,0};
struct termios term , termbak;
char ch;
fd_set fd;
FD_ZERO(&fd);
FD_SET( STDIN ,&fd);
tcgetattr(STDIN, &term);
termbak = term;
term.c_lflag &= ~(ICANON|ECHO);
tcsetattr(STDIN, TCSANOW, &term);
while(1)
{
FD_ZERO(&fd);
FD_SET( STDIN ,&fd);
if( 1 == select( STDIN+1,&fd,NULL,NULL,&tv)
&& 1 == read( STDIN , &ch , 1 )
&& 'q' == tolower(ch) )
break;
putchar('.');fflush(stdout);
usleep(100000);
}
tcsetattr(STDIN,TCSANOW,&termbak);
return 0;
}
转载自:http://topic.csdn.net/u/20100115/10/7ec685ee-27ef-4b03-b184-ce0a1e728cde.html
相关文档:
总览
用iptables -ADC 来指定链的规
则
,-A添加 -D删除 -C 修改
iptables - [RI] chain rule num rule-specification[option]
用iptables - RI 通过规则的顺序指定
iptables -D chain rule num[option]
删除指定规则
iptables -[LFZ] [chain][option]
用iptables -LFZ 链名 [选项]
iptables -[NX] chain
用 -NX ......
名称:cat
使用权限:所有使用者
使用方式:cat [-AbeEnstTuv] [--help] [--version] fileName
说明:把档案串连接后传到基本输出(萤幕或加 > fileName 到另一个档案)
参数:
-n 或 --number 由 1 开始对所有输出的行数编号
-b 或 --number-nonblank 和 -n 相似,只不过对于空白行不编号
-s 或 --squeez ......
在写这篇文章的时候,有323个不同的发行版
被
distrowatch.com关注。有的被称作Ehad,有的叫做EstrellaRoja。很多名字里面都有包括一个“X”字母,一些展示特性的吉祥
物和自己的交流社区。他们当中并不是所有的都是完全基于Linux基础框架和发展活跃的,但大多数主流发行版如此。这是一个选择多样的世界,是 ......