From a6cac46c1741cc686da46585c16b17c2acb9f416 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Thu, 4 Jul 2002 19:57:57 +0000 Subject: * libtool.m4: New file. * libc/sys/linux/process.c: Implement vfork in terms of fork, rather than as a syscall. --- newlib/libc/sys/linux/process.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'newlib/libc/sys/linux/process.c') diff --git a/newlib/libc/sys/linux/process.c b/newlib/libc/sys/linux/process.c index 0419ec7ef..8ae58b0c5 100644 --- a/newlib/libc/sys/linux/process.c +++ b/newlib/libc/sys/linux/process.c @@ -4,6 +4,7 @@ #include +#include #include @@ -11,7 +12,6 @@ #define __NR__execve __NR_execve _syscall0(int,fork) -_syscall0(pid_t,vfork) _syscall3(int,_execve,const char *,file,char * const *,argv,char * const *,envp) _syscall0(int,getpid) _syscall2(int,setpgid,pid_t,pid,pid_t,pgid) @@ -21,6 +21,25 @@ _syscall0(pid_t,setsid) weak_alias(__libc_getpid,__getpid); +pid_t vfork(void) +{ + pid_t pid; + + pid = fork(); + + if(!pid) + { + /* In child. */ + return 0; + } + else + { + /* In parent. Wait for child to finish. */ + if (waitpid (pid, NULL, 0) < 0) + return pid; + } +} + /* FIXME: get rid of noreturn warning */ #define return for (;;) -- cgit v1.2.3