![]() |
parent and child processes
I have a problem to make a program that is going to create n processes.
The first process, which is initial program, creates the second process, which in turn creates the third process, and so on until the nth process is created. my code so far looks like this and when i run it some child processes create more then one child process (every process should create only one child!) any suggestions how to fix this? Code:
|
Quote:
Code:
PARENTYou will have to stop any process from creating more than one process to implement that |
Quote:
But the thing is i have to make it so it every parent creates only one child and its child creates only one child an so on... so my question is do you know how i can fix my code so i can get structure like this Code:
PARENT |
posted twice: look at the next one
|
you will have to check the return value of the fork() call.
In the parent process, fork() will return the pid of the child, while the fork() returns 0 in the child process. So if you don't want both processes to create a new process you will have to do something like this. Code:
// in makeprocess() |
thank you guys
i fixed my code... |
| All times are GMT -5. The time now is 06:36 PM. |