传送门:http://cboard.cprogramming.com/c-programming/63166-kbhit-linux.html

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h> int kbhit(void)
{
struct termios oldt, newt;
int ch;
int oldf; tcgetattr(STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= ~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
oldf = fcntl(STDIN_FILENO, F_GETFL, );
fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK); ch = getchar(); tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
fcntl(STDIN_FILENO, F_SETFL, oldf); if(ch != EOF)
{
ungetc(ch, stdin);
return ;
} return ;
} main( int argc, char** argv )
{
char *input = argv[];
int nomor = argc;
pid_t pid = ;
/* set stuff up */
/* accept command line args */ pid = fork();
if( pid == ){
/* this is the "background" process. Execute process loop here */
int x=;
while()
{
if(kbhit())
printf("you hit keyboard");
}
}
else {
/* "foreground" process exits */
exit();
}
}

具体含义,有的解释是等待键盘输入;但此处用意为在 ios下使用while( !kbhit()) 控制openal的音效的循环播放.

_kbhit() for linux的更多相关文章

  1. Linux 驱动开发

    linux驱动开发总结(一) 基础性总结 1, linux驱动一般分为3大类: * 字符设备 * 块设备 * 网络设备 2, 开发环境构建: * 交叉工具链构建 * NFS和tftp服务器安装 3, ...

  2. play snake on linux

    在写完超Low的windows上的贪吃蛇后 被人吐槽了几个方面: 1.界面真的Low,开始,结束,游戏中,都太简陋了... 2.每次都清屏在输出字符矩阵的解决方案...太晃眼了 3.一个BUG,为了解 ...

  3. Linux 内核概述 - Linux Kernel

    Linux 内核学习笔记整理. Unix unix 已有40历史,但计算机科学家仍认为其是现存操作系统中最大和最优秀的系统,它已成为一种传奇的存在,历经时间的考验却依然声名不坠. 1973 年,在用 ...

  4. 死磕内存篇 --- JAVA进程和linux内存间的大小关系

    运行个JAVA 用sleep去hold住 package org.hjb.test; public class TestOnly { public static void main(String[] ...

  5. NodeJs在Linux下使用的各种问题

    环境:ubuntu16.04 ubuntu中安装NodeJs 通过apt-get命令安装后发现只能使用nodejs,而没有node命令 如果想避免这种情况请看下面连接的这种安装方式: 拓展见:Linu ...

  6. [linux]阿里云主机的免登陆安全SSH配置与思考

    公司服务器使用的第三方云端服务,即阿里云,而本地需要经常去登录到服务器做相应的配置工作,鉴于此,每次登录都要使用密码是比较烦躁的,本着极速思想,我们需要配置我们的免登陆. 一 理论概述 SSH介绍 S ...

  7. Linux平台 Oracle 10gR2(10.2.0.5)RAC安装 Part3:db安装和升级

    Linux平台 Oracle 10gR2(10.2.0.5)RAC安装 Part3:db安装和升级 环境:OEL 5.7 + Oracle 10.2.0.5 RAC 5.安装Database软件 5. ...

  8. Linux平台 Oracle 10gR2(10.2.0.5)RAC安装 Part1:准备工作

    Linux平台 Oracle 10gR2(10.2.0.5)RAC安装 Part1:准备工作 环境:OEL 5.7 + Oracle 10.2.0.5 RAC 1.实施前准备工作 1.1 服务器安装操 ...

  9. SQL Server on Linux 理由浅析

    SQL Server on Linux 理由浅析 今天的爆炸性新闻<SQL Server on Linux>基本上在各大科技媒体上刷屏了 大家看到这个新闻都觉得非常震精,而美股,今天微软开 ...

随机推荐

  1. The web application you are attempting to access on this web server is currently unavailable.......

    今天去服务器安装了个.net 4.0 framework(原本有1.0和2.0的),配置好站点后,选择版本为4.0,访问出错,错误代码如下 Server Application Unavailable ...

  2. Leetcode 35

    //在数组最后插入INT_MAX是个好方法class Solution { public: int searchInsert(vector<int>& nums, int targ ...

  3. windows安装mysql方法 mysql5.7以后的安装方法

    mysql 安装步骤: 1.www.mysql.com   下载mysql 2.解压mysql到E盘,或者其他盘解压后   E:\mysql\bin   (bin一定要按照这个目录) 3.这bin目录 ...

  4. 在ubuntu16中部署Django使用memcached作为缓存

    Django支持很多缓存系统,如 文件系统缓存. 数据库缓存. 内存缓存(Memcached),其中,Memcached是最快的,没有之一,是绝配.因为所有的缓存数据都放在内存,没有了IO延迟,也没有 ...

  5. 客户端链接Blog

    Word 2013链接Blog 1.设置共享->发布至博客->发布至博客 2.新建博客账户 3.添加新建账户信息 注意:URL内为Blog名,而非用户名 a) 在"Type of ...

  6. please complete all spokes before continuing 提示

    解决方法:输入“1”,按Enter键输入“2”,按Enter键输入“q",按Enter键输入“yes”,按Enter键

  7. Python 傅里叶分析

    0. 一维序列卷积 np.convolve,注意 same/valid参数下(默认为 full),序列卷积出的结果的长度: >> np.convolve([1, 2, 3], [0, 1, ...

  8. supervisor 使用tips

    Supervisor (http://supervisord.org) 是一个用 Python 写的进程管理工具,可以很方便的用来启动.重启.关闭进程,supervisor可以同时监控多个进程,并可以 ...

  9. MAC远程桌面连接问题

    如图,始终提示“证书或相关链无效.” 点击“取消” 点击“编辑连接...” 点击“打开” 点击“安全性” 选择“即使验证失败,也始终连接” OK

  10. Documentation/filesystems/sysfs.txt 文档翻译--sysfs

    sysfs - 用于导出内核对象的文件系统. 1.sysfs是一个基于ram的文件系统,最初基于ramfs. 它提供了一种方法,可以将内核数据结构,它们的属性以及它们之间的链接导出到用户空间.sysf ...