Clone (Linux System Call)

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:

#include int clone (int (*fn) (void *), void *child_stack, int flags, void *arg);

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:

    Women of my age in America are at the mercy of two powerful and antagonistic traditions. The first is the ultradomestic fifties with its powerful cult of motherhood; the other is the strident feminism of the seventies with its attempt to clone the male competitive model.... Only in America are these ideologies pushed to extremes.
    Sylvia Ann Hewitt (20th century)

    Short of a wholesale reform of college athletics—a complete breakdown of the whole system that is now focused on money and power—the women’s programs are just as doomed as the men’s are to move further and further away from the academic mission of their colleges.... We have to decide if that’s the kind of success for women’s sports that we want.
    Christine H. B. Grant, U.S. university athletic director. As quoted in the Chronicle of Higher Education, p. A42 (May 12, 1993)