#define FORK_VFORK 0x1 pid_t fork(int flags, int cluster);
This syscall creates a new process based on the parent process. The created process will only have 1 thread copying the caller one, and will be placed on the passed thread cluster.
flags
is a bitmap that can be used to customize the forking operation,
the values that can be passed are:
FORK_VFORK
: Instead of cloning the address space of the parent process.
The child will use the same address space until an exec
is done. During
that time between fork
and exec
, the parent process will be
halted. Thus, both processes will never share the same address space.
This is provided for increased speed, as we can avoid copying memory just to trash it with exec.
This syscall returns 0
on success for the child, and the new child PID
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.
EACCES
: MAC disallowed this.