views:

155

answers:

1

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.

+3  A: 

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

app.StandardInput.Close()

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:

open $fh, "| $command > outputfile 2> errorfile";
close $fh;

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.

mobrule
A slightly safer, more modern idiom for the open process call would be `open $fh, '|-', "$command ..."`
mobrule
This is all good but i am on windows and i need to do something like that perl code so ffmpeg will F@#$%ing finish and not lock up. What part causes STDIN to be null Is it the |- part (or |)? I am using .NET and i am already setting properties to redirect std out and err. What is fh? in .NET i specific the exe and the arguments. | appears to go in front of the exe which leaves me confused. -edit- +1 for your informal answer.
acidzombie24
This answer is fully correct! stdin had nothingt to do about it and i now know a little more about nul and std
acidzombie24