async, watches and blocking/unblocking



Hello list,
I spawn 2 programs with g_spawn_async_with_pipes. stdout on the first
goes to stdin on the second. stdout on the second is written to file.
I use g_io_channel_unix_new to create the channels for the stdins and
stdouts.

I use g_io_add_watch to setup calls to the callback functions (one for
output from the first program (feeds stdin channel for the second
program) and one for output on the second (writes to file through a
channel)) and g_io_channel_read/write_char to read/write the channels
in the callbacks.

My problem is that unless I set all the channels to be non-blocking
the program will hang in a g_io_channel_read/write_char somewhere.

Is there a way of doing this without setting the channels to non_blocking? 

Alternatively, is there an elegant way of doing this with the channels
non_blocking, at the moment I do a lot of tests on G_IO_STATUS_AGAIN.

I know this is a rather short description of the problem, but I think
I am missing something rather essential when it comes to treating
pipes between asynchronously running programs so I hope it should be
enough for some bright soul to point me in the right direction.

rgds,

Ole C.



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