c - 如何在非规范模式下从读取函数返回且 VMIN 和 TIME 不等于零

标签 c linux unix terminal system-calls

我在一个项目中工作,我需要从我的 Linux (Ubuntu 12.04 LTS) 计算机的 USB 端口读取数据。

我正在使用读取函数以非规范模式从终端读取数据,并且 VTIME = 5(0.5 秒)和 VMIN = 255,这意味着它将阻塞直到第一个字符到达,然后计时器将启动为在这里声明:

In case of both TIME and MIN are nonzero. In this case, TIME specifies how long to wait after each input character to see if more input arrives. After the first character received, read keeps waiting until either MIN bytes have arrived in all, or TIME elapses with no further input. read always blocks until the first character arrives.

我想做的是,如果超过 5 秒没有收到任何字符,则强制从读取函数返回。

我该怎么办?!

最佳答案

正如我在这里读到的:http://www.gnu.org/software/libc/manual/html_node/Noncanonical-Input.html

VTIME = 50

会做。

关于c - 如何在非规范模式下从读取函数返回且 VMIN 和 TIME 不等于零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22979730/

相关文章:

c++ - 使用 C 从事件目录访问用户信息

c++ - POSIX 套接字和 BSD 套接字有什么区别?

linux - SayDigits 在 Asterisk 中不起作用

linux - 有没有办法提取 Artifactory 的存储摘要?

linux - curl 中的 -v verbose 有什么区别?

linux - tar: 无法将目录更改为 <dir>/<file>: 不是目录

c - 解释 scanf 中没有空格和 scanf 中有空格有什么区别?

c - 内存泄漏和可能的 malloc 错误

c - C、C++中的指针

python-3.x - 有没有办法使用python将不同的作业(进程)分配给linux中的特定核心?