Re: g_spawn_async_with_pipes and g_io_add_watch problems



On Fri, 3 Dec 2004 09:17:03 -0500
Tristan Van Berkom <tristan van berkom gmail com> wrote:

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 ?
my main process was locking on writing to gzip's stdin or on reading
from gzip's stdout. this was because I wasn't checking if I can write to
gzip's stdin.


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).
can I use g_io_channel_get_buffer_condition instead of select?

thanks for your advice

-- 
Hubert Sokolowski




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