This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [Leif Johansson <leifj@matematik.su.se>] libc/1323: daemon hangs subsequent calls to pthread_create



I've looked again at the bug report and noticed some interesting
points.

>>>>> Andreas Jaeger writes:
 > From: Leif Johansson <leifj@matematik.su.se>
 > Subject: libc/1323: daemon hangs subsequent calls to pthread_create
 > X-Sent: 7 weeks, 5 hours, 42 minutes, 47 seconds ago

 > Topics:
 >    libc/1323: daemon hangs subsequent calls to pthread_create


 > ----------------------------------------------------------------------

 > Date: Fri, 24 Sep 1999 15:25:28 +0200
 > From: Leif Johansson <leifj@matematik.su.se>
 > To: bugs@gnu.org
 > Subject: libc/1323: daemon hangs subsequent calls to pthread_create
 > Message-Id: <199909241325.PAA00884@puh.matematik.su.se>


>> Number:         1323
>> Category:       libc
>> Synopsis:       The daemon function prevents any calls to pthread_create to return
[...]
	
 > If a process calls daemon(0,0) before calling pthread_create to create
 > a thread, the call to pthread_create will not return. When I replaced
 > the call to daemon in my code with the daemon which comes with libroken
 > (from kth-krb, heimdal or arla), pthread_create works fine.
>> How-To-Repeat:
 > #include <pthread.h>

 > /*
 >  * The code should simply terminate with an exit code of 47
 >  * from the child but instead it leaves two sickly threads. Some 
 >  * logging would easily reveal that it never gets to pthread_join.
 >  * remove the call to daemon avoids the problem
 >  */
 
 > static void *
 > doit(void *ptr)
 > {
 >   pthread_exit(ptr);
 > }
 
 > int
 > main()
 > {
 >   pthread_t thread;
 >   int i = 47;
 >   void *ret = NULL;
 
 >   daemon(0,0);
 >   pthread_create(&thread,NULL,&doit,&i);
 >   pthread_join(thread,&ret);
 >   exit(*(int *)ret);
 > }
The program works fine for me with glibc 2.1.2 (plus some patches).
This might have been fixed in the meantime.  Please note that you will
not see the exit code of 47 if you call daemon.

>> Fix:
 > Use the daemon from arla, kth-krb or heimdal (i.e from the "roken" library).

If this helped, then something else is broken.  I've checked
arla-0.29.2 and it uses *exactly* the same daemon implementation as
glibc (compare arla-0.29.2/lib/roken/daemon.c with
glibc-2.1.2/misc/daemon.c).

I'm closing the report soon,
Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.rhein-neckar.de

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]