g_spawn_async_with_pipes woes

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,
                NULL, NULL, NULL,   
                &std_in, &std_out, NULL,

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);

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

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!

#include <stdio.h>
#include <string.h>

  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]