[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: reading GIOChannel causes "Segmentation fault"



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)	  guint *readBytes;
> (058)	  gchar *buffer;
> ..
> (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
>
>
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>

-- 
      __          _    __ David Helder - dhelder@umich.edu
  ___/ /__ __  __(_)__/ / <http://www.eecs.umich.edu/~dhelder>
 / _  / _ `/ |/ / / _  /  Jungle Monkey: <http://www.junglemonkey.net>
 |_,_/|_,_/|___/_/|_,_/   Paper CD Case: <http://www.papercdcase.com>





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]