SPUG: system() eating STDIN, how to avoid?
james at banshee.com
Thu Jun 30 19:48:15 PDT 2005
I've got some code that reads from STDIN. Occasionally this code needs to
call system() to generate an audio file.
Something in the system() call seems to be eating from standard input,
though. If I stop in the debugger right before the system() call, and do
I see all the remaining input that I expect. And at this point I understand
that that input has been eaten, so I restart. If I step through the
system() call, then do the same
DB<89> x <STDIN>
I've tried things like replacing the command I intend to run inside system()
with system('ls') and get the same results, which surprised me.
I tried it with system('ls < /dev/null > /dev/null') and also got the same
results (nothing left in STDIN after system().
What am I missing here? What's the right way to protect STDIN? Note that I
don't want the thing run in the system() call to have access to this input.
More information about the spug-list