- clone (Linux system call)
-
clone()
is a system call on the Linux kernel related to multithreading. In practice, one should try to avoid calling clone() directly, but instead use a threading library (such as pthreads) which use clone() when starting a thread (such as during a call to pthread_create()).The syntax for calling
clone
under a Linux program is:#include <sched.h> 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 thefn
argument (as opposed to fork() which continues with the next command after fork().) Thechild_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, andarg
is the argument passed to the function. It returns the process ID of the child process or -1 on failure.See also
- Native POSIX Thread Library – POSIX implementation of thread functions for Linux
- POSIX Threads
Linux operating system Linux Adoption (Adopters) · Criticism (of desktop Linux) · History · Kernel (kernel names · supported architectures) · Linus' Law · Linux Foundation · Linux-libre · Tux · vmlinuxDistribution GNU Free Software Foundation · GNU · GNU GPL · GNU/Linux naming controversy · GNU packages · GNU ProjectWindow manager User interface Applications People Media Lists System arrangement
and featuresMobile Access Linux Platform · Android · Ångström · bada · LiMo Foundation · LiMo Platform · Linux Phone Standards Forum · MeeGo (Maemo · Moblin) · Mobilinux · Open Handset Alliance · Openmoko · OPhone · webOS · SHR · Ubuntu MobileOther topics Linux conference · Linux Documentation Project · Malware · Linux Standard Base · Linux User Group (LUG) · Revolution OS · SCO and Linux · Tanenbaum–Torvalds debate · The CodeCategories:- Linux
- Operating system APIs
Wikimedia Foundation. 2010.