Browse Source

vfork: Use clone if arch does not have the vfork syscall

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Markos Chandras 11 years ago
parent
commit
58570fc8e1
1 changed files with 18 additions and 1 deletions
  1. 18 1
      libc/sysdeps/linux/common/vfork.c

+ 18 - 1
libc/sysdeps/linux/common/vfork.c

@@ -10,7 +10,24 @@
 # 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