summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2015-07-20 13:46:22 +0000
committered <ed@FreeBSD.org>2015-07-20 13:46:22 +0000
commit3200268ec4df725822010e75451026a180f38273 (patch)
treef6b804af4f50292da410fd1a1b757d15d817ee23 /sys/compat
parent7f556435bf73721091bfbf3ea42e18a1c5f86009 (diff)
downloadFreeBSD-src-3200268ec4df725822010e75451026a180f38273.zip
FreeBSD-src-3200268ec4df725822010e75451026a180f38273.tar.gz
Make forking of CloudABI processes work.
Just like FreeBSD+Capsicum, CloudABI uses process descriptors. Return the file descriptor number to the parent process. To the child process we both return a special value for the file descriptor number (CLOUDABI_PROCESS_CHILD). We also return the thread ID of the new thread in the copied process, so the threading library can reinitialize itself. Obtained from: https://github.com/NuxiNL/freebsd
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/cloudabi/cloudabi_proc.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/compat/cloudabi/cloudabi_proc.c b/sys/compat/cloudabi/cloudabi_proc.c
index dba1412..1f4418f 100644
--- a/sys/compat/cloudabi/cloudabi_proc.c
+++ b/sys/compat/cloudabi/cloudabi_proc.c
@@ -33,8 +33,10 @@ __FBSDID("$FreeBSD$");
#include <sys/proc.h>
#include <sys/signalvar.h>
#include <sys/syscallsubr.h>
+#include <sys/unistd.h>
#include <compat/cloudabi/cloudabi_proto.h>
+#include <compat/cloudabi/cloudabi_syscalldefs.h>
int
cloudabi_sys_proc_exec(struct thread *td,
@@ -65,9 +67,15 @@ int
cloudabi_sys_proc_fork(struct thread *td,
struct cloudabi_sys_proc_fork_args *uap)
{
+ struct proc *p2;
+ int error, fd;
- /* Not implemented. */
- return (ENOSYS);
+ error = fork1(td, RFFDG | RFPROC | RFPROCDESC, 0, &p2, &fd, 0);
+ if (error != 0)
+ return (error);
+ /* Return the file descriptor to the parent process. */
+ td->td_retval[0] = fd;
+ return (0);
}
int
OpenPOWER on IntegriCloud