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

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

Re: fork vs __fork in threads (PR libc/1273)


Ulrich Drepper <drepper@cygnus.com> writes:

|> Andreas Schwab <schwab@suse.de> writes:
|> 
|> > I think we need __libc_fork, but for vfork this is impossible to fix,
|> > because we cannot use a wrapper.
|> 
|> We can simply avoid using vfork in MT programs by using the old vfork
|> implementation in libpthread.

Ok, this patch fixes the PR.

Andreas.


1999-09-03  Andreas Schwab  <schwab@suse.de>

	* ptfork.c (__fork): Renamed from fork and use __libc_fork.  Add
	fork as weak alias.
	(__vfork): New function, alias vfork.
        * Versions: Export __fork, vfork, and __vfork in libpthread.

Index: linuxthreads/Versions
===================================================================
RCS file: /glibc/cvsfiles/libc/linuxthreads/Versions,v
retrieving revision 1.11
diff -u -a -r1.11 linuxthreads/Versions
--- linuxthreads/Versions	1999/08/20 00:11:37	1.11
+++ linuxthreads/Versions	1999/09/03 16:27:15
@@ -46,6 +46,7 @@
     __close; __connect; __fcntl; __lseek; __open; __read; __send; __wait;
     __write;
     _IO_flockfile; _IO_ftrylockfile; _IO_funlockfile;
+    vfork; __fork;
 
     # POSIX.1c extensions to libc.
     flockfile; funlockfile; ftrylockfile;
@@ -115,5 +116,6 @@
   }
   GLIBC_2.1.2 {
     __pthread_kill_other_threads_np;
+    __vfork;
   }
 }
Index: linuxthreads/ptfork.c
===================================================================
RCS file: /glibc/cvsfiles/libc/linuxthreads/ptfork.c,v
retrieving revision 1.3
diff -u -a -r1.3 linuxthreads/ptfork.c
--- linuxthreads/ptfork.c	1998/11/18 17:00:24	1.3
+++ linuxthreads/ptfork.c	1999/09/03 16:27:15
@@ -73,11 +73,11 @@
   for (/*nothing*/; list != NULL; list = list->next) (list->handler)();
 }
 
-extern int __fork(void);
+extern int __libc_fork(void);
 
-int fork(void)
+pid_t __fork(void)
 {
-  int pid;
+  pid_t pid;
   struct handler_list * prepare, * child, * parent;
 
   pthread_mutex_lock(&pthread_atfork_lock);
@@ -86,7 +86,7 @@
   parent = pthread_atfork_parent;
   pthread_mutex_unlock(&pthread_atfork_lock);
   pthread_call_handlers(prepare);
-  pid = __fork();
+  pid = __libc_fork();
   if (pid == 0) {
     __pthread_reset_main_thread();
     __fresetlockfiles();
@@ -96,3 +96,10 @@
   }
   return pid;
 }
+weak_alias (__fork, fork);
+
+pid_t __vfork(void)
+{
+  return __fork();
+}
+weak_alias (__vfork, vfork);


1999-09-03  Andreas Schwab  <schwab@suse.de>

	* sysdeps/unix/sysv/linux/syscalls.list: Rename strong name for
	fork from __syscall_fork to __libc_fork.
	* posix/Versions: Add __libc_fork and __vfork to version
	GLIBC_2.1.2.

Index: posix/Versions
===================================================================
RCS file: /glibc/cvsfiles/libc/posix/Versions,v
retrieving revision 1.4
diff -u -a -u -r1.4 posix/Versions
--- posix/Versions	1999/04/09 02:16:20	1.4
+++ posix/Versions	1999/09/03 16:34:46
@@ -84,4 +84,8 @@
     # w*
     waitid; wordexp; wordfree;
   }
+  GLIBC_2.1.2 {
+    # functions used in other libraries
+    __libc_fork; __vfork;
+  }
 }
Index: sysdeps/unix/sysv/linux/syscalls.list
===================================================================
RCS file: /glibc/cvsfiles/libc/sysdeps/unix/sysv/linux/syscalls.list,v
retrieving revision 1.68
diff -u -a -r1.68 sysdeps/unix/sysv/linux/syscalls.list
--- sysdeps/unix/sysv/linux/syscalls.list	1999/07/27 00:23:51	1.68
+++ sysdeps/unix/sysv/linux/syscalls.list	1999/09/03 16:27:34
@@ -11,7 +11,7 @@
 delete_module	EXTRA	delete_module	3	delete_module
 fdatasync	-	fdatasync	1	fdatasync
 flock		-	flock		2	__flock		flock
-fork		-	fork		0	__syscall_fork	__fork fork
+fork		-	fork		0	__libc_fork	__fork fork
 get_kernel_syms	EXTRA	get_kernel_syms	1	get_kernel_syms
 getegid		-	getegid		0	__getegid	getegid
 geteuid		-	geteuid		0	__geteuid	geteuid

-- 
Andreas Schwab                                  "And now for something
schwab@suse.de                                   completely different."
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg

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