beginner fork question

beginner fork question

Post by zero » Thu, 22 Feb 2001 04:58:31



I understand that fork() creates a child proces. But is this exact like the
proces it was called from?

Maybe it is better when I have a tutorial on fork(). So does anyone know
where a good tutorial is availble
or some good and easy to understand example programs?

thnx
--
I have only come here seeking knowledge,
things the wouldn't teach me on college.
Green Lizard

 
 
 

beginner fork question

Post by Lew Pitch » Thu, 22 Feb 2001 05:16:21




Quote:>I understand that fork() creates a child proces. But is this exact like the
>proces it was called from?

Almost exactly. It differs only in a few, system-related values such
as processid, etc. As far as the logic of the program is concerned,
the child process is exactly the same as the parent process.

Quote:>Maybe it is better when I have a tutorial on fork(). So does anyone know
>where a good tutorial is availble
>or some good and easy to understand example programs?

>thnx
>--
>I have only come here seeking knowledge,
>things the wouldn't teach me on college.
>Green Lizard

Lew Pitcher
Information Technology Consultant
Toronto Dominion Bank Financial Group


(Opinions expressed are my own, not my employer's.)

 
 
 

beginner fork question

Post by Arthur H. Gol » Thu, 22 Feb 2001 05:15:35



> I understand that fork() creates a child proces. But is this exact like the
> proces it was called from?

Yes. At the time of return from fork() they will be
indistinguishable (with the exception of having different
pids, etc.)
Quote:

> Maybe it is better when I have a tutorial on fork(). So does anyone know
> where a good tutorial is availble
> or some good and easy to understand example programs?

> thnx
> --

I would recommend that you read the FAQ, specifically the
section on fork() (actually, read the whole thing...you'll
be glad you did).

It can be found at:

URL: http://www.erlenstar.demon.co.uk/unix/faq_toc.html
or
URL: http://www.whitefang.com/unix/faq_toc.html

HTH,
--ag

--
Artie Gold, Austin, TX  (finger the cs.utexas.edu account
for more info)

--
Verbing weirds language.

 
 
 

1. a beginner question , fork() and memory

Most propably i do not understand the subject so well , but i have a
tricky question.
i read that fork() duplicates the process code , data and stack along
with other things , my quesiton here is that , if the parent process
is a large process consuming a lot of memory and the child is just a
small process , after fork() is called by the parent , can it fail
just because there isn't enough memory for the duplicate though it is
enough for the child ( a small process ) to excute ? and even if
paging was used , wouldn't it cause a lot of unnecessary paging out of
physical memory just to make room for the duplicate though only a
small piece of code ( that of the child ) is all what will be
necessary after exec() is used ?

thanks and forgive me if the terms "small" and "big" processes are not
accurate.

2. username > 8 chars in /etc/passwd?

3. comsat forking, forking and forking (3.2.0)

4. Hi! To new to the Unix!

5. beginner-help with fork& signal fncs

6. Is there any Lint-like program available?

7. Beginners: Here's the beginners web info you've been looking for

8. nntp 1.5.12.1 & Linux

9. fork call without using function fork()

10. Efficiency: fork() w/ shared libraries vs. fork()/exec()

11. to fork or to pre-fork

12. Beginner's network question

13. Getting online : beginner question...