summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorMarkos Chandras <markos.chandras@imgtec.com>2012-10-11 10:27:44 +0100
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2013-02-20 13:45:12 +0100
commit58570fc8e1fd601f15be5758ab95013d56771804 (patch)
tree5eecadbd20cc52fc8a537fa3513e9d5d2c8b4847 /libc
parentc7d36adfc2f4b6660602f3f5ed8079b4830158c2 (diff)
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>
Diffstat (limited to 'libc')
-rw-r--r--libc/sysdeps/linux/common/vfork.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/libc/sysdeps/linux/common/vfork.c b/libc/sysdeps/linux/common/vfork.c
index a70ed4a63..a85156d38 100644
--- a/libc/sysdeps/linux/common/vfork.c
+++ b/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