Re: g_spawn_async_with_pipes and g_io_add_watch problems



On Fri, 3 Dec 2004 13:47:19 +0100 (CET), Hubert Sokolowski
<h sokolowski wsisiz edu pl> wrote:

Hi!

I execute from my program dd and gzip both using g_spawn_async_with_pipes.
dd reads from a file and outputs data to stdout. stdout from dd is added
with g_io_add_watch. stdout from gzip is also added with g_io_add_watch.
in function that reads from dd I have a loop that reads whole data.
in that function I execute
 while (gtk_events_pending ())
        gtk_main_iteration ();
so my UI is refreshed and main loop is iterated.
but after few iterations in my loop my program locks on writing to channel
that is connected to stdin of gzip.
how to fix this problem so the function that reads from stdout gzip is
executed.
I was trying to return from the first function that reads from dd after
reading one block of data (not to the end of the data) but there was no
difference.

I probably do something wrong. how to connect this two programs together?

So the problem is that your main process is blocking on write to gzip's stdin
while it should be reading from gzip's stdout right ?

I would sugest simply "not blocking" on write to gzip's stdin.
(i.e. make sure all your reads/writes are one byte at a time and
use select() to check if the descriptor is ready or not, dont just
read/write).

Cheers,
                                                                -Tristan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]