Clone (function)
|
clone() is a function in C on Linux, providing Multithreading. The syntax is:
#include <sched.h> int clone(int (*fn)(void *), void *child_stack, int flags, void *arg);
clone creates a new thread that starts with function pointed to by the first argument (as opposed to Fork() which continues with next command after fork().) The "Stack" is pointer to a memory space to be used as 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 decide what gets inherited from the parent process, and arg is the argument passed to the function. It returns PID of the child process or -1 on failure.