我如何像这个 perl 代码一样将 null 传递到 stdin ?
这是我的问题,显然 这是回答。事实证明这是一个缓冲区问题(解决方案在我的 ffmpeg 链接的接受答案中)而不是标准输入。我发现你可以通过写 > 将标准输出设置为 null命令提示符中的 NUL 所以我尝试编写 < NUL 在我的论点末尾。运气不好。
我如何传入 null 或像 Perl 代码那样对 IO 锁执行某些操作,以便我可以让我的 ffmpeg 脚本在 15 秒左右后不锁定?注意:我必须取出 std 和 err 来检查故障。
This is my question and apparently this is the answer. Turns out it was a buffer problem (solution in the accepted answer of my ffmpeg link) not stdin. I found you can stdout to null by writing > NUL in command prompt so i tried writing < NUL at the end of my argument. No luck.
How do i pass in null or do something with the IO locks like that perl code does so i can get my ffmpeg script not locking up after 15 or so seconds? NOTE: I must get std out and err to check for failures.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新: 之前的回复是关于如何关闭 Perl 生成的进程上的标准输入,但问题实际上是关于如何在 .NET 中执行该任务。
这个想法是一样的。您想要关闭新进程的标准输入流的句柄。 完成此操作
在 .NET 中,可以在调用
app.Start()
后立即。 (我认为您还需要设置
app.StartInfo.RedirectStandardInput = true
,但我不是一个 .NET 程序员,对此我也不确定)。NUL
是 Windows 约定,就像 Unix 的/dev/null
一样。但在 Unix> 上NUL
将创建一个名为"NUL"
的文件,并且< NUL
将导致您的系统调用(即系统
、反引号等)失败,除非存在名为“NUL”
的文件。也就是说,Perl 中有一些可移植的方法可以关闭生成进程的标准输入。例如:
将启动
$command
并立即关闭$command
的标准输入句柄,就好像您从命令行运行命令并立即点击^D
。Update: The previous response was about how to close stdin on a process spawned from Perl, but the question is really about how to perform the task in .NET.
The idea is the same. You want to close the handle to the new process's standard input stream. In .NET, that can be done with
immediately after the call to
app.Start()
.(I think you'll also want to set
app.StartInfo.RedirectStandardInput = true
, but I'm not much of a .NET programmer and I'm not sure about that).NUL
is a Windows convention, like Unix's/dev/null
. But on Unix> NUL
will create a file called"NUL"
, and< NUL
will cause your system call (i.e.system
, backticks, etc.) to fail unless there is a file called"NUL"
.That said, there are portable ways in Perl to close the standard input to a spawned process. For example:
will launch
$command
and immediately close$command
's standard input handle, as if you ran the command from the command line and immediately hit^D
.