working of fork and exec

Mulyadi Santosa mulyadi.santosa at
Thu Jan 17 12:59:36 EST 2013

Hi :)

On Fri, Jan 18, 2013 at 12:02 AM, Niroj Pokhrel <nirojpokhrel at> wrote:
> Hi all,
> I have been using fork and exec for sometime. But I have no idea about what
> are the things done by the kernel when we fork or exec and how things work.
> How the kernel load new program and what all things are done ....... Can
> anybody please explain me this ? Thank you in advance.

this is too broad to answer, but in general fork() does:
- preparing new address space
- preparing new task_struct
- doing COW (copy on write), so newly born child initially simply use
parent's pages

in exec() case, instead of COW, you load the target binary. It does so
by the work of loader in user space and ELF interpreter in the kernel


Mulyadi Santosa
Freelance Linux trainer and consultant


More information about the Kernelnewbies mailing list