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 ......
.tar
解包: tar xvf FileName.tar
打包:tar cvf FileName.tar DirName
(注:tar是打包,不是压缩!)
---------------------------------------------
.gz
解压1:gunzip FileName.gz
解压2:gzip -d FileName.gz
压缩:gzip FileName
.tar.gz
解压:tar zxvf FileName.tar.gz
压缩:tar zcvf FileName.tar.g ......
一.Linux进入与退出系统
进入Linux系统:
必须要输入用户的账号,在系统安装过程中可以创建以下两种帐号:
1.root–超级用户帐号(系统管理员),使用这个帐号可以在系统中做任何事情。
2.普通用户–这个帐号供普通用户使用,可以进行有限的操作。
一般的Linux使用者均为普通用户,而系统管理 ......
Linux, named after the inventor, Linus Torvalds, is a so different OS for everyone against Windows. To everyone who used to use Windows, Linux need us to do more for everything which we usually do by computer, such as playing a video.
Someone says, Linux is for the ones who are good at the computer ......
压缩文件
压缩单个文件
tar zvfc a.tar.gz a.txt
压缩文件夹
tar zvfc a.tar.gz 文件夹路劲
解压缩
tar xvf FileName.tar
如果是 .tar.gz文件首先需要
解压1:gunzip FileName.gz
解压2:gzip -d FileName.gz
在tar 一下 就行了
其他转载
.tar
解包: tar xvf FileName.tar
......