#define CLONE_PARENT 0b01 #define CLONE_THREAD 0b10 pid_t clone(void *callback, uint64_t arg, void *stack, int flags, void *tls);
This syscall creates a new thread or process depending on flags
.
flags
can be an OR’d combination of the following flags:
CLONE_PARENT
(0b01): The process or thread will be a child of the parent
of the caller process, instead of the caller process itself.
CLONE_THREAD
(0b10): If set, a thread will be created and added to the
parent process, if not set, a process will be created instead. The child
process will only have the callee thread cloned. The other threads, if any,
are not cloned.
This syscall returns 0
on success for the child, and the children PID or
TID to the parent, in failure, the parent gets -1
with the following
errno:
EAGAIN
: The system could not create the entity right now, try again
later.
EINVAL
: CLONE_PARENT
is specified and the caller process has no
parent.
EACCES
: MAC disallowed this.