.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Copyright (c) 1992 Drew Eckhardt , March 28, 1992 .\" May be distributed under the GNU General Public License. .\" Modified by Michael Haardt .\" Modified Sat Jul 24 13:22:07 1993 by Rik Faith .\" Modified 21 Aug 1994 by Michael Chastain : .\" New man page (copied from 'fork.2'). .\" Modified 10 June 1995 by Andries Brouwer .\" .TH CLONE 2 "10 June 1995" "Linux 1.2.9" "Linux Programmer's Manual" .SH NAME clone \- create a child process .SH SYNOPSIS .B #include .br .B #include .sp .BI "pid_t clone(void *" "sp" ", unsigned long " "flags" ")" .SH DESCRIPTION .B clone is an alternate interface to .BR fork , with more options. .B fork is equivalent to .BR "clone(0, SIGCLD|COPYVM)" "." If .I sp is non-zero, the child process uses .I sp as its initial stack pointer. The low byte of .I flags contains the signal sent to the parent when the child dies. .I flags may also be bitwise-or'ed with either or both of .B COPYVM or .BR COPYFD . If .B COPYVM is set, child pages are copy-on-write images of the parent pages. If .B 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 .B COPYFD is set, the child's file descriptors are copies of the parent's file descriptors. If .B COPYFD is not set, the child's file descriptors are shared with the parent. .BR .SH "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 .I errno will be set appropriately. .SH ERRORS .TP .B ENOSYS .B clone will always return this error, unless your kernel was compiled with .B CLONE_ACTUALLY_WORKS_OK defined. .TP .B EAGAIN .B fork cannot allocate sufficient memory to copy the parent's page tables and allocate a task structure for the child. .SH BUGS By default, .B CLONE_ACTUALLY_WORKS_OK is not defined. .br There is no entry for .B clone in .BR /lib/libc.so.4.5.26 . .br Comments in the kernel as of 1.1.46 indicate that it mis-handles the case where .B COPYVM is not set. .SH CONFORMING TO This call is Linux-specific and should not be used in programs intended to be portable. .SH "SEE ALSO" .BR fork (2)