且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查是否CLI程序从标准输入等待输入?

更新时间:2023-11-17 23:39:28

一些上面所说的意见,一旦它已经开始在等待你不能检查,如果你的程序是等待标准输入。你可以使用一个事件处理程序,或者你可以简单地读从超时,在这里您正在等待输入,并开始再次超时等待超时你标志的发生。

as some of the comments above have said, you cannot check if your program is waiting for stdin once it has already started waiting. You could use an event handler or you could simply have a read from stdin with a timeout, where on occurrence of the timeout you flag that you are waiting for input and start waiting with a timeout again.