OSDN Git Service

vfork: Use clone if arch does not have the vfork syscall
authorMarkos Chandras <markos.chandras@imgtec.com>
Thu, 11 Oct 2012 09:27:44 +0000 (10:27 +0100)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Wed, 20 Feb 2013 12:45:12 +0000 (13:45 +0100)
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
libc/sysdeps/linux/common/vfork.c

index a70ed4a..a85156d 100644 (file)
 # include <unistd.h>
 extern __typeof(vfork) __vfork attribute_hidden;
 
-# ifdef __NR_vfork
+# if defined __NR_clone && !defined __NR_vfork
+# include <signal.h>
+# include <sys/types.h>
+
+pid_t __vfork(void)
+{
+       pid_t pid = INLINE_SYSCALL(clone, 4, SIGCHLD,
+                                  NULL, NULL, NULL);
+
+       if (pid < 0)
+               return -1
+
+       return pid;
+}
+weak_alias(__vfork, vfork)
+libc_hidden_weak(vfork)
+
+# elif defined __NR_vfork
 #  define __NR___vfork __NR_vfork
 _syscall0(pid_t, __vfork)
 # else