What process does fork(); create ??

The title of my thread says it all..
I've just started learning Operating System.. My question may seems very stupid to you.. but honestly I don't any thing about that really..
I'm just really confused what process does fork(); command creates ??
And my second question why do we need fork(); to create process ??
E.g In my opinions x=4+6 is also a process..
I've seen many examples of using fork(); function but.. what they all did is nothing.. just an output message "I'm a parent with child ID=3867" and blah blah blah.. what does this program do ??
Thanks in advance..
Fork clones the current process, then the new process calls one of the exec() functions to load a new executable. There's probably more to it but that is the gist of it.

Have you looked at the man pages for fork() and exec()?
Have you looked at the man pages for fork() and exec()?

yes I have..
which process does it clone ??
It says in the man page for fork():

fork() creates a new process by duplicating the calling process. The new process,
referred to as the child, is an exact duplicate of the calling process, referred to as
the parent, except for the following points:
Last edited on
E.g In my opinions x=4+6 is also a process..

The execution of a software program over the time is called a process. Its state is defined by its variable assignments. Forking a process duplicates its variables along with their current assignments. From now on there are two threads of execution changing state of their own set of variables possibly in a different manner.
You're doing an Operating Systems course and you don't know what a process is?

x=4+6; is a statement. Statements produce a set of instructions that have to be run somehow.

It's probably easier to answer your question with a question. How does your program run a child program?

For example, how does the shell run ls or any other command?
Last edited on
x=4+6; is a statement.

On the other hand, see:
<https://en.wikipedia.org/wiki/Occam_(programming_language)>
Topic archived. No new replies allowed.