Windows 相当于“/dev/stdin"? [英] Windows equivalent to "/dev/stdin"?

查看:51
本文介绍了Windows 相当于“/dev/stdin"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 Python 代码与只接受文件名的 C++ 库对话.我希望它从标准输入读取.在 Unix 机器上,我可以使用/dev/stdin".我以为我可以在 Windows 上使用特殊的CON"设备,但这更像是/dev/tty,因为echo something | my_program"不起作用.

I have Python code talking to a C++ library which only takes filenames. I want it to read from stdin. On Unix machines I can use "/dev/stdin". I thought I could use the special "CON" device on Windows, but that's more like /dev/tty in that "echo something | my_program" does not work.

在 Windows 下支持管道不是必需的,但现在我很好奇.该操作系统是否有类似文件名/dev/stdin"的内容?

Supporting pipes under Windows isn't essential, but now I'm curious. Is there something like the filename "/dev/stdin" for that OS?

推荐答案

据我所知,没有等效的/dev/stdin.但是,如果您确实需要,您可以创建自己的命名管道 (CreateNamedPipe) 并将名称传递给 C++ 库,使用单独的线程将来自 stdin 的输入提供给命名管道.

To the best of my knowledge there is no equivalent of /dev/stdin. However, if you really needed to you could create your own named pipe (CreateNamedPipe) and pass the name to the C++ library, using a separate thread to feed the input from stdin into the named pipe.

这篇关于Windows 相当于“/dev/stdin"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆