Re: Binary writing to an input pipe and ASCII reading from an output one
- From: Colossus <colossus 3000 it>
- To: Olivier Sessink <lists olivier pk wau nl>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Binary writing to an input pipe and ASCII reading from an output one
- Date: Tue, 25 Oct 2005 08:42:13 -0700
Olivier Sessink wrote:
what does that function do? I guess it calls g_spawn_async_with_pipes(),
right?
Yes.
gulong SpawnAsyncProcess (const gchar *command , gboolean
ExitStatusFlag , gboolean input_pipe)
{
GError *error = NULL;
gchar **argv;
int argcp;
g_shell_parse_argv ( command , &argcp , &argv , NULL);
if ( ! g_spawn_async_with_pipes (
NULL,
argv,
NULL,
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
NULL,
NULL,
&child_pid,
input ? &input_fd : NULL,
&output_fd,
&error_fd,
&error) )
{
response = ShowGtkMessageDialog (GTK_WINDOW
(MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,
error->message);
g_error_free (error);
g_strfreev ( argv );
return FALSE;
}
g_strfreev ( argv );
//The following callback is needed for evaluating the exit status
of the launched compressor
if ( ExitStatusFlag ) g_child_watch_add ( child_pid ,
(GChildWatchFunc) ExitStatus , NULL );
return (gulong) child_pid;
does it correctly create pipes for stdin and stdout? And do you
convert those into GIOChanells?
GIOChannel *SetIOChannel (gint fd, GIOCondition cond, GIOFunc func,
gpointer data)
{
GIOChannel *ioc;
ioc = g_io_channel_unix_new ( fd );
g_io_add_watch (ioc, cond, func, data);
g_io_channel_set_encoding (ioc, "ISO8859-1" , NULL);
g_io_channel_set_flags ( ioc , G_IO_FLAG_NONBLOCK , NULL );
return ioc;
}
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
You are right.
and are they all non-blocking?
Yes.
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.
The problems is that executing cat archive.cpio gives "bad" characters
in the terminale because the file is not ASCII but binary. That
message from cpio, skipped xxxx bytes of junk , is what who stumbles
me but I have correctly set the encoding. How will you do Olivier to
fix this problem ?
--
Colossus
Xarchiver, a GTK2 only archive manager - http://xarchiver.sourceforge.net
Cpsed, a Linux OpenGL 3D scene editor - http://cpsed.sourceforge.net
Mizio, a QT proxy hunter scanner tool - http://mizio.sourceforge.net
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]