about summary refs log tree commit diff
path: root/nptl/sysdeps/unix/sysv/linux/i386/pt-vfork.S
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux/i386/pt-vfork.S')
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/pt-vfork.S21
1 files changed, 20 insertions, 1 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/pt-vfork.S b/nptl/sysdeps/unix/sysv/linux/i386/pt-vfork.S
index 6994c0d7fa..24f5a1d292 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/pt-vfork.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/pt-vfork.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Andreas Schwab <schwab@gnu.org>.
 
@@ -21,6 +21,21 @@
 #define _ERRNO_H	1
 #include <bits/errno.h>
 #include <kernel-features.h>
+#include <tcb-offsets.h>
+
+/* Save the PID value.  */
+#define SAVE_PID \
+	movl	%gs:PID, %edx; 						      \
+	movl	%edx, %eax;						      \
+	negl	%eax;							      \
+	movl	%eax, %gs:PID
+
+/* Restore the old PID value in the parent.  */
+#define RESTORE_PID \
+	testl	%eax, %eax;						      \
+	je	1f;							      \
+	movl	%edx, %gs:PID;						      \
+1:
 
 /* Clone the calling process, but without copying the whole address space.
    The calling process is suspended until the new process exits or is
@@ -31,10 +46,14 @@ ENTRY (__vfork)
 	/* Pop the return PC value into ECX.  */
 	popl	%ecx
 
+	SAVE_PID
+
 	/* Stuff the syscall number in EAX and enter into the kernel.  */
 	movl	$SYS_ify (vfork), %eax
 	int	$0x80
 
+	RESTORE_PID
+
 	/* Jump to the return PC.  Don't jump directly since this
 	   disturbs the branch target cache.  Instead push the return
 	   address back on the stack.  */