Re: redirecting output to a file with g_spawn_async
- From: Chris Vine <chris cvine freeserve co uk>
- To: gtk-app-devel-list gnome org
- Cc:
- Subject: Re: redirecting output to a file with g_spawn_async
- Date: Thu, 6 Oct 2005 10:03:28 +0100
On Thursday 06 October 2005 18:48, Colossus wrote:
Olivier Sessink 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.
Hi,
I did it but the file written is not the same as the original !
I opened with fwrite with "w" since wb does not care on Unix.
I read the data from the pipe in a gchar *line with and write it to
the file with fwrite ( line , 1 , strlen ( line ), fd ) but the
dimension of the written file are not the same of the one extracted
with bzip2 -d file.bz2 and it corrupteded. Where am I wrong ?
Really thanks for your help,
See:
man 2 read
man 3 strlen
In particular: (1) Why do you assume that the input which you have read
comprises a null terminated string? (2) Have you allowed for a short read
from Unix read()?
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]