Re: Fwd: Re: gnome_show_url() hangs in threaded programs [pawsa theochem kth se]



On 2001.08.23 23:38 Pawel Salek wrote:
> I have forgotten to mention: I have gthread library from
> glib-1.2.10-ximian, kernel-2.4.3-12, and pthread from glib-2.2.2-10 (if
> that matters).
> 
> /Pawel
> 
> On 2001.08.22 21:52 Pawel Salek wrote:
> > I have impression that something has got broken in gnome_show_url() and
> > related functions (or perhaps, a bug has surfaced that has not been
> > active earlier).
> 
> After closer investigation, I think the problem is in gthread library. I
> attach a test program with does some threading and forking at the same
> time. 
> The program WorksForMe(TM) when compiled as follows:
> # cc atfork-test.c -lthread
> 
> The program hangs when compiled as follows:
> # cc atfork-test.c -lgthread -lglib
> 
> I think it should not happen so (and gnome programs hang because they
> link
> against gthread). Can someone confirm it? Offer a solution?
Like I said, I'm seeing the same behaviour.

However, it turns out that the program works if I do
% cc atfork-test.c -lgthread -lglib -lpthread -o atfork-test

I think this may present a possible work-around. For balsa, -lpthread is
included already, so it's not just a matter of inserting it, but the link
command is _very_ messy right now (some libs, including pthreads, are
specified several times, there are a lot of references to /usr/lib<lib>.so,
even for libs were -l<lib> is included, etc.), so perhaps you should try to
clean it up a bit?


> 
> /Pawel
> 
> 
> /* Pawel Salek, pawsa@theochem.kth.se, 2001-08-23
> 
>    Rest of pthread_atfork() function.
> 
>    The program WorksForMe(TM) when compiled as follows:
>    cc atfork-test.c -lthread
> 
>    The program hangs when compiled as follows:
>    cc atfork-test.c -lgthread -lglib
> */
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <sys/wait.h>
> #include <pthread.h>
> 
> void* my_thread(void*a)
> {
>     int i;
>     for(i=0; i<5; i++) {
> 	printf("mythread, i=%i\n", i);
> 	sleep(2);
>     }
>     return NULL;
> }
> 
> void prepare_parent()
> {
>     printf("ATFORK: prepare_parent\n");
> }
> 
> void resume_parent()
> {
>     printf("ATFORK: resume_parent\n");
> }
> 
> void resume_child()
> {
>     printf("ATFORK: resume_child\n");
> }
> 
> int main(int argc, char* argv[])
> {
>     pthread_t a_thread;
>     pid_t pid;
>     void* ret;
>     int status;
> 
>     pthread_atfork(prepare_parent, resume_parent, resume_child);
>     pthread_create(&a_thread, NULL, my_thread, NULL);
> 
>     sleep(1);
>     switch( (pid=fork()) ) {
>     case 0: printf("Child is here\n"); exit(0); break;
>     case -1: printf("Fork failed\n"); break;
>     default: printf("Parent, waiting for child %i\n", pid);
> 	wait(&status);
>     }
>     printf("Main thread waits for the thread to join.\n");
>     pthread_join(a_thread, &ret);
>     return 0;
> }
> 
> -- 
> -----
> Pawel Salek, pawsa@theochem.kth.se
> 
> _______________________________________________
> balsa-list mailing list
> balsa-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/balsa-list
> 




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