Fwd: Re: gnome_show_url() hangs in threaded programs [pawsa theochem kth se]
- From: Pawel Salek <pawsa theochem kth se>
- To: gnome-devel-list gnome org
- Cc: balsa-list gnome org
- Subject: Fwd: Re: gnome_show_url() hangs in threaded programs [pawsa theochem kth se]
- Date: Thu, 23 Aug 2001 23:38:42 +0200
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?
/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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]