libglib2, Emacs and GTK applications

Angelo Graziosi angelo.graziosi@alice.it
Mon Feb 8 14:31:00 GMT 2010


Just for completeness, I want to flag some strange things that I see 
between a GTK build of Emacs and libglib2.0_0-2.22.4-2 BUT NOT with 
libglib2.0_0-2.22.4-1!

With 2.22.4-2, when I open a dialog box (for example clicking on the 
tool bar icon "Reading an existing file into an Emacs buffer"), in /tmp 
is created the directory 'fam-angelo' and 'ps' shows a 'gamin-server' 
running. When I quit from Emacs (C-x C-c), the Emacs window stays on the 
desktop until 'gamin-server' is removed, i.e. for at least 20-30 
seconds, looking as if Emacs were hanging.

This behavior does not happens with version 2.22.4-1. The 
'/tmp/fam-angelo' directory is not created and 'gamin-server' or is not 
started or it is removed immediately when it does not need any more. 
Also the 'apparent' hanging disappears.

The above facts should be verified also with the following test case of 
GTK application I found in this list. It should be build with:

gcc -DTRY1 -Wall -o test-dialog3-try1-01 test-dialog3.c `pkg-config 
--cflags --libs gtk+-2.0


Then

$ ./test-dialog3-try1-01.exe

under libglib2-2.22.4-2 creates /tmp/fam-angelo and starts 
'gamin-server' which is removed only after 20-30 seconds. With 2.22.4-1, 
it is removed imediately (or does not start at all!).

Ciao,
Angelo.


test-dialog3.c
============================================
#include <gtk/gtk.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
/* When testing the FAM daemon*/
#ifdef TRY2
#include <fam.h>
#endif

int main( int   argc,
           char *argv[] )
{

   GtkWidget *main_window;
   GtkWidget *button;

   gtk_init (&argc, &argv);
   main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   button = gtk_button_new_with_label ("Show");

   /*  Commenting either of the 3 lines below allows it to work. */
   gtk_container_add (GTK_CONTAINER (main_window), button);
   gtk_widget_show (button);
   gtk_widget_show (main_window);

#ifdef TRY1
   {
     GtkWidget *dialog;
     printf("Using gtk_file_chooser_dialog_new.\n");
     dialog = gtk_file_chooser_dialog_new ("Open File",
       NULL,
       GTK_FILE_CHOOSER_ACTION_OPEN,
       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
       GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
       NULL);
   }
#else
#ifdef TRY2
   /* The code below is called from _fam_sub_startup in glib2 */
   {
     FAMConnection fc;
     printf("Using FAMOpen2.\n");
     if (FAMOpen2 (&fc, "gvfs user") != 0)  {
       printf ("FAMOpen failed, FAMErrno=%d\n", FAMErrno);
       printf ("FAM Error Message: %s\n",FamErrlist[FAMErrno]);
     } else {
       FAMClose(&fc);
     }
   }
#else
   /* The code below is called from gamin_fork_server in gamin*/
   {
     int ret, pid, status;
     printf("Using fork twice in a row.\n");
     pid = fork();
     if (pid == 0) {
       printf("First fork.\n");
       if (fork() == 0) {
	printf("Second fork.\n");
	execl("/usr/bin/ls.exe", "/usr/bin/ls.exe", NULL);
       }
       /*
        * calling exit() generate troubles for termination handlers
        * for example if the client uses bonobo/ORBit
        */
       _exit(0);
     }
     /*
      * do a waitpid on the intermediate process to avoid zombies.
      */
   retry_wait:
     ret = waitpid(pid, &status, 0);
     if (ret < 0) {
       if (errno == EINTR)
	goto retry_wait;
     }
   }
#endif
#endif
   printf("Done.\n");
#if defined (TRY1) || defined (TRY2)
   printf("Please make sure the FAM daemon is not running "
	 "before testing again.\n");
   printf("(i.e. kill the gam_server process or wait until it is gone)\n");
#endif
   return 0;
}
============================================

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/



More information about the Cygwin-xfree mailing list