[uClibc-cvs] uClibc/libpthread/linuxthreads ptfork.c,1.1,1.2

Erik Andersen andersen at uclibc.org
Wed Nov 5 02:12:59 UTC 2003


Update of /var/cvs/uClibc/libpthread/linuxthreads
In directory winder:/tmp/cvs-serv23938/libpthread/linuxthreads

Modified Files:
	ptfork.c 
Log Message:
Arthur Shipkowski, art ! videon-central ! com, writes:

I've noticed a few people have posted over the last year about problems
compiling programs that use vfork when pthreads are involved.  Some
detective work turned up that ptfork.c aliases vfork to fork and then tries
to call the original fork as __libc_fork.  This patch removes the aliasing
when there is no MMU present, and uses the same call semantics to call
__libc_vfork.  I then added a symbol to the m68k vfork.S to allow vfork to
be called as __libc_vfork.

The same bug exists in the uClibc CVS, and with a possible tweak this patch
should go through there as well.

Obviously, all other platforms need __libc_vfork as a workable means to call
vfork in order for this to work for them.

Let me know if there are any problems with this patch.

Art Shipkowski
Videon Central Software Engineer
(814)235-1111 x307



Index: ptfork.c
===================================================================
RCS file: /var/cvs/uClibc/libpthread/linuxthreads/ptfork.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ptfork.c	20 Feb 2002 09:18:44 -0000	1.1
+++ ptfork.c	5 Nov 2003 02:12:56 -0000	1.2
@@ -74,7 +74,7 @@
 {
   for (/*nothing*/; list != NULL; list = list->next) (list->handler)();
 }
-
+#ifdef __UCLIBC_HAS_MMU__
 extern int __libc_fork(void);
 
 pid_t __fork(void)
@@ -105,3 +105,27 @@
   return __fork();
 }
 weak_alias (__vfork, vfork);
+#else
+pid_t __vfork(void)
+{
+  pid_t pid;
+  struct handler_list * prepare, * child, * parent;
+
+  pthread_mutex_lock(&pthread_atfork_lock);
+  prepare = pthread_atfork_prepare;
+  child = pthread_atfork_child;
+  parent = pthread_atfork_parent;
+  pthread_mutex_unlock(&pthread_atfork_lock);
+  pthread_call_handlers(prepare);
+  pid = __libc_vfork();
+  if (pid == 0) {
+    __pthread_reset_main_thread();
+    __fresetlockfiles();
+    pthread_call_handlers(child);
+  } else {
+    pthread_call_handlers(parent);
+  }
+  return pid;
+}
+weak_alias (__vfork, vfork);
+#endif




More information about the uClibc-cvs mailing list