Function do_clone

Source
pub unsafe fn do_clone(ctx: &ucontext, event: &ShimEventAddThreadReq) -> i64
Expand description

Execute a native clone syscall, creating a new thread, which may be in a new process (depending whether CLONE_THREAD is set).

If CLONE_THREAD is set, then the newly created child thread will resume execution from ctx, which should be the point where the managed code originally made a clone syscall (but was intercepted by seccomp). Otherwise this function will return normally in both the parent and child processes.

§Safety

  • ctx must be dereferenceable, and must be safe for the newly spawned child thread to restore.
  • Other pointers, if non-null, must be safely dereferenceable.
  • child_stack must be “sufficiently big” for the child thread to run on.
  • tls if provided must point to correctly initialized thread local storage.