Re: Binary writing to an input pipe and ASCII reading from an output one



Colossus wrote:
Hi,

I'm trying without success to implement cat /tmp/file.cpio | cpio -tv
with g_spawn family and giochannels. My code is to use
"g_spawn_async_with_pipes" with both input and output pipes the "cpio
-tv" command and then I open in read mode the binary cpio archive (I
don't spawn cat just use g_io_channel_new_file):

gchar buffer[65536];
gsize bytes_read;
GError *error = NULL;
GIOChannel *ioc , *input_ioc;

 compressor_pid = SpawnAsyncProcess ( "cpio -tv" , 0 , 1);

what does that function do? I guess it calls g_spawn_async_with_pipes(),
right? does it correctly create pipes for stdin and stdout? And do you
convert those into GIOChanells?

I suppose you have 3 IO channels for your code:
- one to read the file
- one pipe to pass that data to cpio
- one to read the result from cpio

is that correct?

and are they all non-blocking?

the best trick for debugging is probably to spawn 'cat', read some text
file, and print everything you read from the stdout of the process to
the terminal. The terminal should then show exactly the contents of your
text file if everything is OK.

regards,
        Olivier Sessink





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