g_spawn_async_with_pipes woes
- From: John Coppens <john jcoppens com>
- To: gnome-devel-list gnome org
- Subject: g_spawn_async_with_pipes woes
- Date: Mon, 8 Aug 2005 13:45:54 -0300
Hello all.
I first posted this on the gtk-app-devel list, but maybe this list is
more correct:
After hours of trying, I still cannot get g_spawn_async_with_pipes
working in both directions (stdin and stdout piped at the same time).
Here's the call:
ok = g_spawn_async_with_pipes("/tmp", argv, NULL,
G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL,
&std_in, &std_out, NULL,
&error);
The std_out file descriptor is linked to a g_io_watch by:
gio_stdout = g_io_channel_unix_new(std_out);
g_io_channel_set_flags(gio_stdout, G_IO_FLAG_NONBLOCK, NULL);
iow_out = g_io_add_watch(gio_stdout, G_IO_IN, io_out_watch, out_txtbff);
g_io_channel_unref(gio_stdout);
This works if I put NULL instead of the &std_in in the call.
Inversely, if I disable the &std_out (by putting NULL), std_in starts
working.
To have better control over the program called, I wrote the small test
program below...
Could someone please indicate what I doing wrong, or indicate some
example of g_spawn_async_with_pipes where both channels are redirected?
Thanks in advance!
John
#include <stdio.h>
#include <string.h>
int
main(void)
{
FILE *logf;
char bff[80];
printf("Here we are with the simple program\n");
do {
fgets(bff, 80, stdin);
bff[strlen(bff)-1] = '\0';
printf("cmd: [%s]\n", bff);
} while (bff[0] != 'x');
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]