易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

Linux之主机硬盘规划

在Linux系统中,几乎所有的硬件装置代号档案都在/dev这个目录中,

IDE硬盘:/dev/hd[a-d]
光驱:/dev/cdrom
软盘:/dev/fd[0-1]
鼠标:/dev/mouse
打印机:/dev/lp[0-2]
USB随身碟,SCSI硬盘:/dev/sd[a-p]
网卡:/dev/eth[0-n]
RAID : /dev/md[0-15]
主机硬盘的主要规划:
1. 最简单的切割方法: Li ......

Linux多进程相关内容

Linux多进程相关内容
版权声明:可以任意转载,但转载时必须标明原作者charlee、原始链接http://tech.idv2.com/2006/10/14/linux-multiprocess-info/以及本声明。
最近在用 perl 写一个Linux下的多进程守护进程,因此研究了一下Linux下的进程相关的知识。现将心得总结一下。主要是关于进程创建和回收。
fork
SIGCHLD信 ......

Why do We Choose 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 ......

Why do We Choose 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 ......

如何选择最适合你的Linux发行版


在写这篇文章的时候,有323个不同的发行版

distrowatch.com关注。有的被称作Ehad,有的叫做EstrellaRoja。很多名字里面都有包括一个“X”字母,一些展示特性的吉祥
物和自己的交流社区。他们当中并不是所有的都是完全基于Linux基础框架和发展活跃的,但大多数主流发行版如此。这是一个选择多样的世界,是 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号