如何检查 CLI 程序是否正在等待来自 stdin 的输入?

编程入门 行业动态 更新时间:2024-10-27 11:18:01
本文介绍了如何检查 CLI 程序是否正在等待来自 stdin 的输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

如何检查刚刚使用 CreateProcess() 启动的 CLI 程序是否正在等待使用 Windows C API 的 stdin 输入?

How can I check if a CLI program, that I just started with CreateProcess(), is waiting for input from stdin with the Windows C API?

推荐答案

正如上面的一些评论所说,一旦程序已经开始等待,您就无法检查它是否正在等待 stdin.您可以使用事件处理程序,或者您可以简单地从标准输入读取超时,在超时发生时您标记您正在等待输入并再次开始等待超时.

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.

这篇关于如何检查 CLI 程序是否正在等待来自 stdin 的输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-18 09:33:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/936310.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序   正在等待   CLI   stdin

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!