fork



      Hello, All.

    I try create a child process in gtk application. And I try create new window with type GTK_TOPLEVEL_WINDOW in child process.
   And I get very strange behaviour. When I try change window size or position or something else, I get on console:

   Xlib: unexpected async reply (sequence 0x1b8)!
   Xlib: unexpected async reply (sequence 0x31d)!
   Gdk-ERROR **: BadIDChoice (invalid resource ID chosen for this connection)
     serial 831 error_code 14 request_code 1 minor_code 0
     Gdk-ERROR **: BadIDChoice (invalid resource ID chosen for this connection)
     serial 908 error_code 14 request_code 1 minor_code 0

     Gdk-WARNING **: GdkWindow 0x5c00017 unexpectedly destroyed

     Gdk-WARNING **: GdkWindow 0x5c00006 unexpectedly destroyed
     Gdk-ERROR **: BadWindow (invalid Window parameter)
     serial 1724 error_code 3 request_code 2 minor_code 0
     Gdk-ERROR **: BadWindow (invalid Window parameter)
     serial 1725 error_code 3 request_code 61 minor_code 0
     Gdk-ERROR **: BadGC (invalid GC parameter)
     serial 1726 error_code 13 request_code 59 minor_code 0
     Gdk-ERROR **: BadDrawable (invalid Pixmap or Window parameter)
     serial 1727 error_code 9 request_code 70 minor_code 0
     Gdk-ERROR **: BadGC (invalid GC parameter)
     serial 1728 error_code 13 request_code 56 minor_code 0
     
   See my code below and sorry for my English. Help me please. I want create windows in child and in parent.

--- begin ---

#include <gtk/gtk.h>
#include <unistd.h>
#include <sys/types.h>

static GtkWidget *create_mw(void);
static void clicked_fork(GtkButton *b);

int 
main(int argc, char *argv[])
{
   gtk_set_locale();
   gtk_init(&argc, &argv);

   create_mw();

   gtk_main();

   return (0);
}

static GtkWidget *
create_mw(void)
{
   GtkWidget	*mw, *foo;

   mw = gtk_widget_new(gtk_window_get_type(),
	 "GtkWindow::type", GTK_WINDOW_TOPLEVEL,
	 NULL);
   gtk_signal_connect(GTK_OBJECT(mw), "destroy",
	 GTK_SIGNAL_FUNC(gtk_main_quit), NULL);

   foo = gtk_button_new_with_label("fork");
   gtk_signal_connect(GTK_OBJECT(foo), "clicked",
	 GTK_SIGNAL_FUNC(clicked_fork), NULL);
   gtk_container_add(GTK_CONTAINER(mw), foo);
   gtk_widget_show(foo);

   gtk_widget_show(mw);

   return (mw);
}

static void
clicked_fork(GtkButton *b)
{
   pid_t	pid;

   pid = fork();

   if (pid != 0)
      return;

   create_mw();
}

--- end ---

-- 
 Best regards,
  -Denis






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