Re: redirecting output to a file with g_spawn_async
- From: Luke Biddell <luke biddell gmail com>
- To: Olivier Sessink <lists olivier pk wau nl>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: redirecting output to a file with g_spawn_async
- Date: Sun, 2 Oct 2005 00:10:40 +0100
or you could do the following I think :)
int* fd = (int*)data;
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 |
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
On 01/10/05, Olivier Sessink <lists olivier pk wau nl> wrote:
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.
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
] [Thread Prev