or you could do the following I think :) static void stdout_setup_func(gpointer data) { int* fd = (int*)data; dup2(*fd, 1); }
void blah() { int fd = open(/*open the file you want to write to*/); /* pass the stdin_setup_func to gspawn */ gint stdout = 0, stderr = 0; g_spawn_async_with_pipes(NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_LEAVE_DESCRIPTORS_OPEN | G_SPAWN_DO_NOT_REAP_CHILD , stdout_setup_func, &fd, NULL, NULL, &stdout, &stderr, NULL)); } So when gspawn creates the child it runs the child stdout func thing and connects the child stdout to your file descriptor and all the output goes to file. It's all along the lines of this post i saw. http://www.mail-archive.com/gnome-devel-list@gnome.org/msg00323.html Hope this helps Luke On 01/10/05, Olivier Sessink <[EMAIL PROTECTED]> wrote: > Colossus wrote: > > Hi, > > > > I tried with g_spawn_async_with_pipes and with gspawn_async > > but it does not work. In the first case the output (the decompressed > > bzip2 file) is redirected to a GTK window so I used g_spawn_async (no > > pipes) but the output is directed to the shell window from which I ran > > my program. How can I have the output redirected to the file /mnt/foo ? > > open a file in write mode, and while reading from the pipe from > _spawn_async, write data to that file. > > regards, > Olivier > > _______________________________________________ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list