【发布时间】:2017-04-06 17:45:23
【问题描述】:
在我的终端上,如果我运行,
> tty
/dev/tty0
> ./myprogram.out
我的程序有getchar(),然后它阻塞在等待来自/dev/tty0 文件输入的stdin(0) 文件描述符。
这个进程也是由 Process mgmt 根据它获得的时间片来调度的。
我的问题是,
getchar() 如何等待stdin? getchar() 内部用于等待 stdin 输入的系统调用是什么?
【问题讨论】:
-
您可以使用
strace查看任何程序进行的所有系统调用。 -
Matteo Italia 的答案可能与您想解决这个问题一样远。再进一步,你就是dealing with TTY stuff。
标签: c linux linux-kernel getchar