fork

Cihangir Akturk cakturk at gmail.com
Mon Apr 18 04:18:50 EDT 2016


On Mon, Apr 18, 2016 at 12:18:00PM +0530, Nitin Varyani wrote:
> Linux kernel development by Robert Love describes the fork process as
> 
> fork() -> clone() -> do_fork() -> copy_process()
> 
> I am unable to find the clone() system call in linux 3.13.
> Can someone explain the proper flow of fork() system call initiated by the
> user?
> 
> Where can I find the libc implementation for fork()? I want the code of all
> the functions involved in fork.

There are a couple of libc implemetations out there, say musl,
dietlibc, uClibc and so on. But If you mean GNU libc aka. glibc
then this is what you are looking for:

https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/nptl/fork.c;h=1a68cbd6476b3268b5b7ac09ae60c35ce7069219;hb=HEAD#l47

__libc_fork() calls clone() syscall internally using a bit of
assembler magic.



More information about the Kernelnewbies mailing list