From f9ccc501f8396ecd950b04a42f73b455ce418867 Mon Sep 17 00:00:00 2001 From: Arun Thomas Date: Fri, 22 Jul 2011 10:55:30 +0200 Subject: [PATCH] Add vfork() system call -Same semantics as fork() as it's really just a stub -Eases porting of BSD utilities --- lib/nbsd_libc/stdlib/system.c | 4 ---- lib/nbsd_libc/sys-minix/MISSING_SYSCALLS | 1 - lib/nbsd_libc/sys-minix/Makefile.inc | 2 +- lib/nbsd_libc/sys-minix/vfork.c | 16 ++++++++++++++++ nbsd_include/unistd.h | 2 ++ 5 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 lib/nbsd_libc/sys-minix/vfork.c diff --git a/lib/nbsd_libc/stdlib/system.c b/lib/nbsd_libc/stdlib/system.c index e5fefa836..f0fc1207e 100644 --- a/lib/nbsd_libc/stdlib/system.c +++ b/lib/nbsd_libc/stdlib/system.c @@ -91,11 +91,7 @@ system(command) } (void)__readlockenv(); -#ifdef __minix - switch(pid = fork() ) { -#else /* !__minix */ switch(pid = vfork()) { -#endif /* !__minix */ case -1: /* error */ (void)__unlockenv(); sigaction(SIGINT, &intsa, NULL); diff --git a/lib/nbsd_libc/sys-minix/MISSING_SYSCALLS b/lib/nbsd_libc/sys-minix/MISSING_SYSCALLS index 22698ab7d..d6de9689c 100644 --- a/lib/nbsd_libc/sys-minix/MISSING_SYSCALLS +++ b/lib/nbsd_libc/sys-minix/MISSING_SYSCALLS @@ -76,4 +76,3 @@ futimes utrace uuidgen vadvise -vfork diff --git a/lib/nbsd_libc/sys-minix/Makefile.inc b/lib/nbsd_libc/sys-minix/Makefile.inc index b9fcb839f..df94abf65 100644 --- a/lib/nbsd_libc/sys-minix/Makefile.inc +++ b/lib/nbsd_libc/sys-minix/Makefile.inc @@ -16,7 +16,7 @@ SRCS+= accept.c access.c bind.c brk.c sbrk.c compat.S \ vectorio.c shutdown.c sigaction.c sigpending.c sigreturn.c sigsuspend.c\ sigprocmask.c socket.c socketpair.c stat.c statvfs.c symlink.c \ sync.c syscall.c sysuname.c truncate.c umask.c unlink.c write.c \ - _exit.c _ucontext.c environ.c __getcwd.c + _exit.c _ucontext.c environ.c __getcwd.c vfork.c # Minix specific syscalls. SRCS+= cprofile.c lseek64.c sprofile.c _mcontext.c diff --git a/lib/nbsd_libc/sys-minix/vfork.c b/lib/nbsd_libc/sys-minix/vfork.c new file mode 100644 index 000000000..9433c8a34 --- /dev/null +++ b/lib/nbsd_libc/sys-minix/vfork.c @@ -0,0 +1,16 @@ +#include +#include "namespace.h" +#include + +#include + +#ifdef __weak_alias +__weak_alias(vfork, _vfork) +#endif + +PUBLIC pid_t vfork() +{ + message m; + + return(_syscall(PM_PROC_NR, FORK, &m)); +} diff --git a/nbsd_include/unistd.h b/nbsd_include/unistd.h index d93a15ff1..9eda37fc2 100644 --- a/nbsd_include/unistd.h +++ b/nbsd_include/unistd.h @@ -289,6 +289,8 @@ int usleep(useconds_t); #ifndef __LIBC12_SOURCE__ pid_t vfork(void) __RENAME(__vfork14); #endif +#else +pid_t vfork(void); #endif /* !__minix */ #ifndef __AUDIT__ -- 2.44.0