[vorbis-dev] piping vorbize's stdout/stderr
Peter Surda
psurda at byte.at
Mon Jul 31 13:48:39 PDT 2000
On Mon, Jul 31, 2000 at 11:14:11AM -0700, Monty wrote:
> > Hi!
> > I want to pipe stdout/stderr from vorbize for wrapper scripts. But as it
> > doesn't send any "\n"s it doesn't work correctly. I solved it by adding
> >
> > if (param.verbose == 1) {
> > fprintf (stderr, "\n");
> > }
> That actually isn't guaranteed to work. The proper thing to do is
> fflush(stderr).
Well, I guess we're both right to some extent. But unless I use a "\n",
---------cut----------
open PIPE, "vorbize blahblahblah|";
while (<PIPE>) {
if (/(\d+\.\d\%)/) {
$status{perc} = $1;
}
}
close PIPE;
---------cut----------
(in Perl) doesn't work. Well it does but the whole progress is treated as 1
line after the encoding has finished. I guess I don't have to explain why this
is unwanted :-)
Although fdflush indeed results in better synchronization, I still have to use
the "\n".
OTOH I could do a
--------cut--------
system ("mkfifo", "/tmp/pipe.stuff");
start_a_new_thread_for system ("vorbize", "blahblahblah", ">&/tmp/pipe.stuff");
sysopen (SOMETHING, "/tmp/pipe.stuff", O_RDONLY|O_SOMETHING_ELSE);
while (tread_running) {
sysread(SOMETHING); # problematic because a line of output doesn't
# have a fixed length
find_out_percent;
}
close (SOMETHING);
--------cut--------
but that's a hell more complicated and prone to bugs.
> Monty
Bye,
Peter Surda (Shurdeek) <surda at bigfoot.com>, ICQ 10236103, +4369910964300
--
If Bill Gates had a dime for every time a Windows box crashed...
...Oh, wait a minute, he already does.
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
More information about the Vorbis-dev
mailing list