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
相关文档:
uname -a
cat /proc/version
cat /etc/issue
lsb_release -a (适用于所有的linux,包括Redhat、SuSE、Debian等发行版,但是在debian下要安装lsb,不安装加上-a参数查看部分)
如:
发行版:
# cat /etc/issue
内核:
# uname -r
......
1、将驱动源码放在/drivers/char/下
2、修改drivers/char/Kconfig文件,添加以下内容:
config My_Buttons
tristate "My_Buttons test"
depends on ARCH_S3C2440
default y if ARCH_S3C2 ......
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 ......
简单解释一下ipcs命令和ipcrm命令。
取得ipc信息:
ipcs [-m|-q|-s]
-m 输出有关共享内存(shared memory)的信息
-q 输出有关信息队列(message queue)的信息
-s 输出有关“遮断器&rdqu ......
压缩文件
压缩单个文件
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
......