Results 1 to 2 of 2
I've working on a project which gives 10 random numbers with the use of rand... I also have to create a Parent process and two Child ones... my problem is ...
- 11-08-2009 #1Just Joined!
- Join Date
- Nov 2009
- Posts
- 6
Question about Fork & Parent-Child process
I've working on a project which gives 10 random numbers with the use of rand... I also have to create a Parent process and two Child ones... my problem is that I can use the fork command to produce one Child but then how do I create-define the second one so that I specify which one is which so that I can then run a qsort and sort the numbers, ascended by the one child and descended by the other... any ideas?
- 11-09-2009 #2
Fork() returns the child's PID to the parent and zero to the child. So you could use fork() twice in succession, making the second call conditional on the first returning non-zero (i.e. that call would occur in the parent only). Then the parent would have two returned PIDs which would uniquely identify the two children.
"I'm just a little old lady; don't try to dazzle me with jargon!"


Reply With Quote
