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 ......
一.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 ......
简单解释一下ipcs命令和ipcrm命令。
取得ipc信息:
ipcs [-m|-q|-s]
-m 输出有关共享内存(shared memory)的信息
-q 输出有关信息队列(message queue)的信息
-s 输出有关“遮断器&rdqu ......
linux下挂载硬盘
用dmesg找出新硬盘的设备名,像/dev/sda等,然后用fdisk分区,创建挂载点,用mkfs创建文件系统,最后挂载 ....
下面是我以前写的,呵呵,希望有帮助
1. 将sici硬盘放入服务器(因为是热插拔,因此不用重启服务器)
2. ......