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
This commit is contained in:
parent
5a170c1b0e
commit
62c31cffae
@ -169,6 +169,16 @@ cloudabi64_set_syscall_retval(struct thread *td, int error)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cloudabi64_schedtail(struct thread *td)
|
||||
{
|
||||
struct trapframe *frame = td->td_frame;
|
||||
|
||||
/* Initial register values for processes returning from fork. */
|
||||
frame->tf_rax = CLOUDABI_PROCESS_CHILD;
|
||||
frame->tf_rdx = td->td_tid;
|
||||
}
|
||||
|
||||
static struct sysentvec cloudabi64_elf_sysvec = {
|
||||
.sv_size = CLOUDABI64_SYS_MAXSYSCALL,
|
||||
.sv_table = cloudabi64_sysent,
|
||||
@ -185,6 +195,7 @@ static struct sysentvec cloudabi64_elf_sysvec = {
|
||||
.sv_set_syscall_retval = cloudabi64_set_syscall_retval,
|
||||
.sv_fetch_syscall_args = cloudabi64_fetch_syscall_args,
|
||||
.sv_syscallnames = cloudabi64_syscallnames,
|
||||
.sv_schedtail = cloudabi64_schedtail,
|
||||
};
|
||||
|
||||
INIT_SYSENTVEC(elf_sysvec, &cloudabi64_elf_sysvec);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user