What process does fork(); create ??

Oct 15, 2015 at 9:24am
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..
Oct 15, 2015 at 10:14am
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()?
Oct 15, 2015 at 10:50am
Have you looked at the man pages for fork() and exec()?

yes I have..
which process does it clone ??
Oct 15, 2015 at 11:05am
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 Oct 15, 2015 at 11:06am
Oct 20, 2015 at 9:50am
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.
Oct 20, 2015 at 1:00pm
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 Oct 20, 2015 at 7:49pm
Oct 20, 2015 at 10:56pm
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.