The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM



Thread: fork() help
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 03-06-2007
alexicopax alexicopax is offline
Registered User
 

Join Date: Mar 2007
Posts: 2
fork() help

Hi everybody,
I wanna write a code to understand how fork works.

my target
--------------

-Parent creates a file(called temp) and writes into this file "1".Then it closes the file.

-Then parent creates a child and wait until execution of this child ends.

-Then child opens the same file and reads the last integer in it. Then, it will multiply this integer by 2 and add 1. Then child appends the result as a new line at the end of the file. After closing the file this child will fork another child process and wait until it finishes its execution.

-Then child which calculates the Nth integer will not fork anymore, and return after writing the result into the file.( N can be taken from user )

Thanks a lot men...
Reply With Quote
Remove advertisements
!!
Forum Sponsor