CLONE(2)

NAME
clone - create a child process

SYNOPSIS
#include <linux/sched.h>
#include <unistd.h>

pid_t clone(void *sp, unsigned long flags)

DESCRIPTION
clone is an alternate interface to fork, with more options. fork is equivalent to clone(0, SIGCLD|COPYVM). If sp is non-zero, the child process uses sp as its initial stack pointer. The low byte of flags contains the signal sent to the parent when the child dies. flags may also be bitwise-or'ed with either or both of COPYVM or COPYFD. If COPYVM is set, child pages are copy-on-write images of the parent pages. If COPYVM is not set, the child process shares the same pages as the parent, and both parent and child may write on the same data. If COPYFD is set, the child's file descriptors are copies of the parent's file descriptors. If COPYFD is not set, the child's file descriptors are shared with the parent.

RETURN VALUE
On success, the PID of the child process is returned in the parent's thread of execution, and a 0 is returned in the child's thread of execution. On failure, a -1 will be returned in the parent's context, no child process will be created, and errno will be set appropriately.

ERRORS

EAGAIN
    fork cannot allocate sufficient memory to copy the parent's page tables and allocate a task structure for the child.

BUGS
There is no entry for clone in /lib/libc.so.4.5.26.
Comments in the kernel as of 1.1.46 indicate that it mis-handles the case where COPYVM is not set.

SEE ALSO
fork(2)