Re: reading GIOChannel causes "Segmentation fault"
- From: Sven Herzberg <herzi runbox com>
- To: David Helder <dhelder umich edu>
- Cc: "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
- Subject: Re: reading GIOChannel causes "Segmentation fault"
- Date: 22 Aug 2001 23:16:41 +0200
Am 20 Aug 2001 19:29:08 -0400 schrieb David Helder:
You need to allocate memory for the buffer.
David
On 19 Aug 2001, Sven Herzberg wrote:
Hi,
when running the following piece of code, i get a "Segmentation fault"
error.
(009) Client::Client() {
..
(012) pipe(fdFromDonkey);
..
(016) pidDonkey = fork();
(017) if (pidDonkey == 0) {
..
(023) dup2(fdFromDonkey[1], fileno(stdout));
..
(028) close(fdFromDonkey[0]);
..
(031) gchar *argvDonkey[1] = NULL;
(032) gchar **argvDonkeyPointer = argvDonkey;
(033) execv("./donkey",argvDonkeyPointer);
..
(036) }
..
(040) fromDonkey = g_io_channel_unix_new(fdFromDonkey[1]);
..
(043) g_io_add_watch(fromDonkey, G_IO_IN, parseText, this);
..
(045) }
(056) gboolean parseText(GIOChannel *source, GIOCondition condition,
gpointer client) {
(057) uint *readBytes = 0;
(058) char buffer[4096];
..
(064) g_io_channel_read(source, buffer, 1, readBytes);
..
(071) return false;
(072) }
When my program reaches line (064), it tells me "Segmentatio fault" and
exits. Why does this happen?
--
sven
Changed it to the prevous (remember this is c++). All values are
initialized.
it's still segfaulting.
Does anyone have example code? (i'm getting weird)
--
sven
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]