clone is a system call in the Linux kernel that creates a child process that may share parts of its execution context with the parent. It is often used to implement multithreading. In practice, clone is not often called directly, but instead using a threading library (such as pthreads) that uses clone when starting a thread (such as during a call to pthread_create).
The syntax for calling clone under a Linux program is:
clone creates a new thread that starts with the function pointed to by the fn argument (as opposed to fork which continues with the next command after fork.) The child_stack argument is a pointer to a memory space to be used as the stack for the new thread (which must be malloc'ed before that; on most architectures stack grows down, so the pointer should point at the end of the space), flags specify what gets inherited from the parent process, and arg is the argument passed to the function. It returns the process ID of the child process or -1 on failure.
Famous quotes containing the words clone and/or system:
“Each writer is born with a repertory company in his head. Shakespeare has perhaps 20 players, and Tennessee Williams has about 5, and Samuel Beckett oneand maybe a clone of that one. I have 10 or so, and thats a lot. As you get older, you become more skillful at casting them.”
—Gore Vidal (b. 1925)
“Human beings are compelled to live within a lie, but they can be compelled to do so only because they are in fact capable of living in this way. Therefore not only does the system alienate humanity, but at the same time alienated humanity supports this system as its own involuntary masterplan, as a degenerate image of its own degeneration, as a record of peoples own failure as individuals.”
—Václav Havel (b. 1936)